1String[] array = {"0","1","2","3","4","5","6","7","8","9"};
2String[] a = Arrays.copyOfRange(array, 0, 4); //<- (targetArray, start, to)
3String[] b = Arrays.copyOfRange(array, 4, array.length);
4
5Output:
6a: 0,1,2,3
7b: 4,5,6,7,8,9
1public class split_demo {
2
3 public static void main (String[] args)
4
5 {
6
7 String str_split="split method.It is cool - (Hello-World)";
8
9 for (String str_complex : str_split.split("\\s|,|\\.|-")) {
10
11 System.out.println(str_complex);
12
13 }
14
15 }
16
17}
18