java - How to run methods from another class -
i new java coding. want know how run methods class without using extends or implements functions.
i have 2 questions on subject.
for organization reasons have set-up subclass under main class has run loop. how can run methods subclass in loop? main class isn't recognizing methods of subclass if proclaimed regularly (if(subclassmethodname()==1);).
also, there anyway me run nonstatic methods class (in totally different file) without using extends or implements?
(i have tried extends , program using run script doesn't seem allow script ran whatever reason). "(classname).class" menu in eclipse seems have lot of options not sure them accomplish goal...
create instance of subclass call method want.
class child{ public void sayhello(){ system.out.println("hello"); } }
from inside parent:
child mychild = new child(); mychild.sayhello();
Comments
Post a Comment