I'm trying to fill an array from keyboard input, but my method gets stuck on the b = in.nextInt();
line, in the second to last value I want to input. I'm confused.
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int a_size;
int duplicate;
System.out.println("Enter test size");
a_size = in.nextInt();
int [] a_array;
a_array = new int[a_size];
int b;
for (int i= 0; i <a_array.length; i++ ){
System.out.println("Enter number");
b = in.nextInt();
a_array[i] = b;
}
System.out.println("Passed");
}
edit: Sorry all the kind folks. I tested the code and its working fine. It was a simple code and I could not see anything wrong with it. I apologize and I agree that I am a bundle of sticks. Please forgive me.