Java program to Split String

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
package basic;
 
public class Splitingstring
 
{
public static void main(String[] args)
 
{ 
 
	String course="java sql dbms html j2EE";
 
	String[] arr1=course.split(" "); 
 
 
	System.out.println("number of courses "+arr1.length);
 
	for(int i=0;i<arr1.length;i++)
	{
		 System.out.println(arr1[i]);
	}
 
   }	
 
}

output:

1
2
3
4
5
6
number of courses 5
java
sql
dbms
html
j2EE

Leave a Reply

Your email address will not be published. Required fields are marked *