How to see the result? | SoloLearn: Learn to code for FREE!

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 !

5/17/2020 5:33:01 PM

Mohammad Ala Tahhan

2 Answers

New Answer

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.

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.