That's not true... It's possible to trick the compiler:
boolean a = true;
while (a)
{
System.out.println("Infinite loop!");
}
System.out.println("I tricked the compiler! This...
Type: Posts; User: helloworld922
That's not true... It's possible to trick the compiler:
boolean a = true;
while (a)
{
System.out.println("Infinite loop!");
}
System.out.println("I tricked the compiler! This...
The reason is that the .nextDouble(), .nextInt(), etc. methods don't consume the new-line character. The user will type something like this:
"123\n" (\n comes from user hitting the return/enter...