package en.codegym.task.pro.task04.task0406;
import java.util.Scanner;
/*
We show what we get
*/
public class Solution {
public static void main(String[] args) {
//write your code here
Scanner sc = new Scanner (System.in);
while (sc.hasNextLine()) {
String a = sc.nextLine();
}
While(true){
if (a = "emough")
{
break;
}
else{ System.out.println(a);}
}
}
}
it is asking the ; after while
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Thomas
17 September 2023, 16:37
In additon to what TheVirus said:
If you check a termination condition in an infinite loop (a equals emough?), then the variable (a) you check should also change at some point. Otherwise the loop runs infinitely (as supposed).
Checking the abort condition is not correct. = is an assignment and even == (comparison) would just compare reverences. You should use equals.
But you never reach this part as the loop (why that) to read in a line is also running endlessly. Even if it wouldn't you won't be able to use the variable a outside the code block you declared it. So it is not known in the second while loop.
Have you tried to add as much mistakes as possible to that piece of code?
+1
TheVirus
17 September 2023, 13:02
You should write "while", not "While"
+1