I implemented this method and wanted to get suggestions and or improvements. The objective of the method is to print the even and odd indexes of Strings contained within an array. Each set of indexes(even and odd) should be seperated by a space.
public static void printEvenOddIndexes(String[] strings){
for(int i = 0; i < strings.length;i++){
String word = strings[i];
ArrayList<Integer> oddIndexes = new ArrayList<>();
for(int j= 0; j < word.length();j++){
if(j % 2 == 0){
System.out.print(word.charAt(j));
}else{
oddIndexes.add(j);
}
}
System.out.print(" ");
for(Integer index : oddIndexes){
System.out.print(word.charAt(index));
}
System.out.println();
}
}