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

*/

 Related Posts:

Check a string value is Integer or not in java. (Solution).

Check  string is hexadecimal number or not (Solution).

Generate Combination in java (Solution).

Generate permutation of string(Solution).

Reverse string in java (Solution).

Find duplicate characters with occurrences in a string(Solution).

Permutation of a number(Soluion).

Split the String in java(Solution).

Convert string into number in java(Solution).

Swap two strings without using any variable(Solution).

Get a number from a string in java(Solution).

Add Two Big Number In Java(Solution).

Expand String(Solution).

Reverse String (Solution).

Leave a Reply

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

83 − = 75