what is a splitindex java code example
Example 1: split method in java
public class SplitExample2 {
public static void main(String args[])
{
String str = "My name is Chaitanya";
//regular expression is a whitespace here
String[] arr = str.split(" ");
for (String s : arr)
System.out.println(s);
}
}
Example 2: split string by index java
String s ="123456789abcdefgh";
String sub = s.substring(0, 10);
String remainder = s.substring(10);