discardemprty strings in spplit operatin in java code example
Example 1: split method in java
public class SplitExample2 {
public static void main(String args[])
{
String str = "My name is Chaitanya";
String[] arr = str.split(" ");
for (String s : arr)
System.out.println(s);
}
}
Example 2: how to split a string in java
public class GFG {
public static void main(String args[])
{
String str = "geekss@for@geekss";
String[] arrOfStr = str.split("@", 2);
for (String a : arrOfStr)
System.out.println(a);
}
}