Does java support nested methods? -


are nested methods possible in java? spring application have found nested methods. please explain.

@bean messageservice mockmessageservice() {     return new messageservice() {         public string getmessage() {           return "hello world!";         }     }; } 

no. nested methods not possible.

your example not show nested methods.

your example returns anonymous class declared , implemented inline!

mockmessageservice method

new messageservice(){ ... } anonymous class implementing messageservice interface

getmessage method in anonymous class implement messageservice interface correctly


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -