share

Saturday, 17 January 2015

Split the String in java

 Split the String in java using split method.
public class StringSplitExample {
public static void main(String[] args) {
String str = "India,America,China,England";

String[] namesOfArray = str.split(",");

System.out.println("Names are: ");

for (String name : namesOfArray)
 {

System.out.println(name);

 }

 }

 }
/*
Output:
Names are:
India
America
China
England

*/

No comments:

Post a Comment