Is there any error in the following code? It shows cant find symbol, symbol: class out location: class System. In the log, it show a lot of errors, including
java.lang.
You can't place code outside methods in Java. You have
System.out.println("Enter the value of r");
which is not belonging to anything. Fix these issues and the problem will go away.
Just for curiosity, how should code outside methods be called and from what according to you? What I mean is that the execution is made by a code flow which starts from a entry point (the main
method in Java) and jumps to methods called, eventually spawning other threads. Code which doesn't reside inside a method is not reachable nor it leads to anything.