What I'm trying to do with this code is that it gives the user a choice between 2 items in a list and the selected item is taken to a new list in the list of lists. I just wanted to know if the implementation of my new list creation is correct or no. I have another non related bug in the program so I can't test if the implementation works or not.
public static void compareTwo(List<List<String>> list){
int result;
for (int j = 0;j<list.size();j++) {
if ((list.get(j).size() / 2) % 2 == 0) {
for (int i = 0; i < list.get(j).size(); i = +2) {
String x = list.get(j).get(i);// gets stuff inside the inner list
String y = list.get(j).get(i+1);
System.out.println("1 ("+x+") or 2 ("+y+")" );
result = Integer.valueOf(scan.nextLine());
list.add(j + 1, new ArrayList<String>() {
});// add another inner list to biglist
list.get(j+1).clear();//clears the new inner list
if (result==1){
String z = list.get(j).get(i);
list.get(j+1).add(z);
}
else{
String z = list.get(j).get(i+1);
list.get(j+1).add(z);
}
}
}