i'm stay crazy i just want use the loop while to read some ages on Java terminal
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
int lenghtMax = 100;
int[] age = new int[lenghtMax];
int status = 1;
String next;
int i = 0;
while(status == 1){
if (i >= 100){
System.out.println("You cant register more ages!\n");
} else {
System.out.println("What the age?");
age[i] = keyboard.nextInt();
i++;
System.out.println("Do you want register other age? y/n");
next = keyboard.next();
if (next == "y"){
status = 1;
} else {
status = 0;
keyboard.close();
}
}
}
System.out.println("Passing Here!");
}
This is my code, where is the error, because it print that message!
Output
What the age?
45
Do you want register other age? y/n
y
Passing Here!
Why it is printing that message?, the code should get back on the while loop, my while is a normal while!