package pkg;
class car{
void mtd2(){
System.out.println("hello,world");
}
void mtd1() {
System.out.println("Invoke 1st method by THIS:");
this.mtd2();// the object itself invoke this, not recommended
System.out.println("Directly invoke 2nd method:");
mtd2();
}
}
public class p85 {
public static void main(String[] args) {
car toyota=new car();
toyota.mtd1();
}
}
OUTPUT:
Invoke 1st method by THIS:
hello,world
Directly invoke 2nd method:
hello,world