class aa { public void bb() { class cc { public void dd() { System.out.println("hello"); } } } } How to call dd() method in main method?
class Solution { public static void main(String arg[]) { /* i want to call dd() here */ } } class aa { public void bb() { class cc { public void dd() { System.out.println("hello"); } } } } How to call dd() method in main method?
class Solution { public static void main(String arg[]) { /* i want to call dd() here */ } } To call an instance method, you need an instance of that method e.g.
class aa { interface ii { public void dd(); } public ii bb() { // you can only call the method of a public interface or class // as cc implements ii, this allows you to call the method. class cc implements ii { public void dd() { System.out.println("hello"); } } return new cc(); } } later
new aa().bb().dd();