+ 1
Can someone explain
i'm getting to error messages that are difficult to debug import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner ae = new scanner(System.in); int Ae = ae.nextint(); System.out.Println("1 to continue and 2 to not"); if (Ae = 1){ do while(Ae = 1){ System.out.Println("lag"); } } else{ System.out.Println(":("); } } } Error messages: ./Playground/Program.java:11: error: while expected } ^ ./Playground/Program.java:12: error: illegal start of expression } else{ ^ 2 errors
3 Answers
+ 3
Hi :) I already see a number of mistakes in your code. As Ipang said, Java is case sensitive. So to accept input, use ae.nextInt(). Also, the p in System.out.println is small not capital. The if statement in your code won't work as an if statement works on a boolean expression or a expression that returns a boolean value. So use '==' to compare numbers. Using one '=' assigns a value to a variable. The while loop is not needed as you have already checked for the same condition earlier in the if statement.
+ 1
You need a review the tutorial on conditionals and loops chapter.
Also remember that Java is a case sensitive language, mind how you declare things and how you refer to them.
0
correct first error here
//do while(Ae = 1){
while (Ae == 1) {