Calling a method from an external class.
  • Create a local variable of the class you want to call.
    • e.g. A a = new A();
    • where Ais an external class and a is a local variable that serves as copy of class A. Here a is also know as an object of class A, as it is derived from class A.
  • Once an object of a class is created, you can access all public member of that external class.
    • e.g. a.method1();
    • here we use a dot operator after the object "a". as shown in the picture below.

//import java io.*;
public class Test_this
public static void main(String args[])//this is an netry function must have
//nameoftheclass varablea = new Nameofthecxlass();
A a=new A();
int n1;
class A
void method1()
System.out.println("hello, my name is baba");
int method2()
System.out.println("hello world");
return 0;

Supporting images: Note that as soon as you create an object from a class, all the class members are accessible through the object "a".