匿名内部クラスの概念を利用するために、これら 2 つのクラスを作成しました。クラス 1 には静的内部クラスがあります。クラス 2 はそれを使用します。しかし、内部クラスのメソッドを呼び出す方法がわかりません。私を助けてください。
クラス1
public class outerclass {
outerclass() {
System.out.println("Constructor of new class");
}
public void showthis(String str) {
System.out.println(str);
}
static class insideclass {
insideclass() {
System.out.println("This is inside class constructor");
}
public void nowshowthis(String str) {
System.out.println(str);
}
}
}
クラス2
public class helloworld {
public static void main(String args[]) {
//this is an object of the outer class
outerclass example=new outerclass();
//How do i make an anonymous inner class and call the method "nowshowthis()"
}
}