I tried to make a little program with Scanner but it says that my While loop is incorrect. The error message is: 'line cannot be resolved to a variable'
I tried to fix this problem, but when I do, another error message comes up!
Here, I put the code:
import java.util.Scanner;
public class Application {
public static void main(String[] args) {
while (line != "yes") {
Scanner input = new Scanner(System.in);
System.out.println("Do you want some chocolate?");
String line = input.nextLine();
System.out.println("You are wrong!");
}
System.out.println("Yup! Good answer! ^.^");
}
}
What is incorrect? Thanks in advance for your understanding.