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

25th Apr 2020, 10:32 AM
David
David - avatar
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
25th Apr 2020, 12:58 PM
Avinesh
Avinesh - avatar
+ 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; }
27th Apr 2020, 12:12 AM
None
+ 1
Move the ruler class outside the item class and give a try
25th Apr 2020, 10:34 AM
Prince
0
output was error occured
25th Apr 2020, 10:37 AM
David
David - avatar
0
It will work once you move it outside the item class. Are you trying to do inner classes?
25th Apr 2020, 10:39 AM
Prince
0
yh
25th Apr 2020, 10:40 AM
David
David - avatar
0
thanks seen the errors
25th Apr 2020, 1:00 PM
David
David - avatar