Tuesday, 29 September 2015

Java Program to Splitting a String

/**
 *
 */

/**
 *
 *
 */
public class Splitstring {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String s = new String("This is Sai from Bangalore");
String a[] = s.split(" ");
for(int i=0;i<5;i++){
System.out.println(a[i]);

}
}

}


Output:-
This
is
Sai
from
Bangalore

No comments:

Post a Comment