How to see the result? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to see the result?

I have written this code, and when I run the program I don't get fail or error, but no result shows up, how do I show the result of this code? : _______________________________________________________________ class Main { public static void main(String[] args) { class ExampleB { float x = 7f; } class ExampleA extends ExampleB { float x = 5f; public void method() { float x = 2f; System .out. println ("The value of x=7 : " + super.x); System .out. println ("The value of x=5 : " + this.x); } } } } _______________________________________________________________ please help !

17th May 2020, 5:33 PM
Mohammad Ala Tahhan
Mohammad Ala Tahhan - avatar
2 Answers
0
The main method is the entry point of your programm. You defined 2 classes in the main method (i dont know if that is even possible, but i would recommend defining the classes just in the Main class), but you never created an object of any of that classes in the main method. So you need to create an object of ExampleA and call the method() on it.
17th May 2020, 6:23 PM
Jnn
Jnn - avatar
0
Btw the class ExampleA and ExampleB are nested classes of the Main class. You also dont need to call it Main class, it is just important to have a main method in a class of your programm.
17th May 2020, 6:28 PM
Jnn
Jnn - avatar