Error in System.out.println

前端 未结 5 1513
独厮守ぢ
独厮守ぢ 2021-01-24 14:59

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.

5条回答
  •  生来不讨喜
    2021-01-24 15:24

    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.

提交回复
热议问题