Calling newly defined method from anonymous class
问题 I instantiated an object of an anonymous class to which I added a new method. Date date = new Date() { public void someMethod() {} } I am wondering if it is possible to call this method from outside somehow similar to: date.someMethod(); 回答1: Good question. Answer is No. You cannot directly call date.someMethod(); Let's understand first what is this. Date date = new Date() { ... }; Above is anonymous(have no name) sub-class which is extending Date class. When you see the code like, Runnable r