Error in System.out.println

前端 未结 5 1579
独厮守ぢ
独厮守ぢ 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

    The following code

    System.out.println("Enter the value of r");
    int r=sc.nextInt();
    System.out.println("enter the value h");
    int h=sc.nextInt();
    

    must be inside a method. Not directly in the class. Classes can contain field and method declarations, but not arbitrary code.

提交回复
热议问题