How can i get the value of a java array using Scanner class with a fixed length of 2, and which will iterate until its value is equal to a given value? For example; for the following inputs,
A G
N H
D F
I wrote a for loop to take the values of fixed array road, in which the length is 2 using Scanner class.
for(int i = 0; i<block.length; i++){
System.out.println("enter number");
block[i]=input2.next().charAt(0);
}
I want to iterate this loop while the user input is {'C','C'}. THat means the array loop shpuld stop if the inputs are as follow;
A G
N H
D F
C C
How can i write the code to take user input values using Scanner class and to iterate the array? And the user input values should be copied without replacing them with newly entered values. Thank you!