java - Call parent method from an instance -


I was thinking about this topic:

But I'm still not sure what the right The terminology is I am trying to do.
I have an example of a test and I want to call a method from "parent" who made an example.

  Public Sector Main {Public Main} Test Test 1 = New Test (); } Public Zero Show Message (String Message) {System.out.println (Message); }} Public Class Test {Public Test} // I Main How do I call the show message ("Testing is going on")? }}   

I had the answer in the subject listed above:

A class you are expanding and considering which is "parent" The method you are calling on is not stable, the following should do the trick:

Supertogleng Visibility ();

If this is a static method - it is also simple:

main. Show message ();

Problem:
I am absolutely sure that I can not use the super because I expand a square I'm not and I'm not sure that main.showMessage (); will work because I did not reference the main in the test class.

You can give an example of a man in the test, and I'm going to help I am using the interface: Public Class Main Equipment Parents {Public Main} (Test 2 Test 2 = New Test 2 (this);} Public Zero Show Message (String Message) {System.out.println (Message);} Public Static Zero Main (String [] Args) {New Head ();}} Interface Parents {Zero Show Sage (String Message);} Class Test 2 {Public Test 2 (Parent) (Parents Show Message ("I'm Running in Test");}}

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -