import java.util.*; public class TwoArrays { public static void main(String[] args) { Scanner in=new Scanner(System.in); int[] list1, list2; list1 = new int[10]; list2 = new int[10]; int num1=0, num2=0; // stores the number of elements in list1 and list2 respectively int i, whichList; System.out.print("Which list should the first number go into, list 1 or 2? Enter 0 to quit "); whichList=in.nextInt(); while(whichList!=0&&num1<10&&num2<10) // why are we including num1<10 and num2<10? { if(whichList==1) { System.out.print("Enter a value for List 1 "); list1[num1++]=in.nextInt(); } else { System.out.print("Enter a value for List 2 "); list2[num2++]=in.nextInt(); } System.out.print("Which list should the next number go into, list 1 or 2? Enter 0 to quit "); whichList=in.nextInt(); } if(num1==10) System.out.println("List 1 is full, quitting"); // why are these two instructions here? else if(num2==10) System.out.println("List 2 is full, quitting"); System.out.println("Here are your two lists:\n\nList 1:"); for(i=0;i