In able to do that, we need to create an instance on another class as:
B b=new B();
b.method();
Or, can create a static method in class like:
class B
{
static void staticMethod();
}
And then, we can call like this:
B.staticMethod();
I hope this will help.
Want to become a Java Expert? Join Java Training now!!
Want to know more about Java? Watch this video on Java Course | Java Tutorial for Beginners :