This site requires JavaScript, please enable it in your browser!
Greenfoot back
Runefyre
Runefyre wrote ...

2013/5/2

How Do You Use A Public Method In One Class From Another Class

Runefyre Runefyre

2013/5/2

#
Titles says it all.
bourne bourne

2013/5/2

#
public class ClassA
{
public static void doStuff()
{}
public void doStuffOnObject()
{}
}

public class ClassB
{
public void main()
{
// Invoke static class method:
ClassA.doStuff();

// Invoke method belonging to instance of ClassA:
ClassA myClassA_Object = new ClassA();
myClassA_Object.doStuffOnObject();
}
}
You need to login to post a reply.