0
Java
public class item { public static void main (String[] args) { class ruler { int length; int breadth; } ruler plastic = new ruler(); plastic.length= 5; plastic.breadth=10; double Area; plastic Area = plastic.length * plastic.breadth; system.out.println ( " output of the ruler is " + plastic Area + " cm ") ; } } Still not running any help
7 odpowiedzi
+ 3
David you need to understand a couple of things well because I could see some errors. But I have tried to make some changes and it works now.
https://code.sololearn.com/csofHlVCnfZv/?ref=app
+ 2
The problem is in main method you have created a class in main method you must create a class out of main method!
public class Item   
{
    public static void main (String[] args) {
    
    Ruler plastic = new Ruler();
    plastic.length= 5;
    plastic.breadth=5;
    
   double area =plastic.length*plastic.breadth;
   System.out.println ( " output of the ruler is " + area + " cm ") ;
  } 
}
class Ruler {
        int length;
        int breadth;
    }
+ 1
Move the ruler class outside the item class and give a try
0
output was error occured
0
It will work once you move it outside the item class. Are you trying to do inner classes?
0
yh
0
thanks seen the errors





