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.
In java does not work like this any behaviour you want to implement you must do it inside a block or a method
It needs to be inside an executable block of code to be executed. Otherwise there's no way to know when to execute it.
Remember that a class can only have attributes or methods.Attributes are the properties of the class and methods represent the behaviour of the class.So every implementation goes inside a method or a block.
The only things allowed outside method and constructor declarations are declarations of fields. Since
Scanner sc=new Scanner(System.in);
System.out.println("Enter the value of r");
int r=sc.nextInt();
System.out.println("enter the value h");
int h=sc.nextInt();
is not a field declaration, it's not allowed.