this is my array:
[UserID|Name|Password|IC or Passport Number|Gender|Phone, 01234567|Bob|abcderf|MALE|01234567]
and I want to convert into:
[UserID|Name|Password|IC or Passport Number] [01234567|Bob|abcderf|MALE|01234567]
this is my code: (but it doesn’t work]
String[] arr = userList.toArray(new String[userList.size()]); String[] arrr = arr[0].split(","); for ( int i=0; i<arr.length;i++) { System.out.println(arr[i]); }
Advertisement
Answer
You can simply use method from Arrays if lenght of array is always the same
String[] array1 = Arrays.copyOfRange(array, 0, 4); String[] array2 = Arrays.copyOfRange(array, 4, 9);