Java - Anonymous Classes


ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
  public void run() {
In the above code, we instantiate an instance of an anonymous class that implements the Runnable interface.  
Creating an instance of an anonymous class involves using the new keyword, followed by the name of an 
interface or the name of a base class, followed by the parentheses, followed by the body of the anonymous 
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License