Java this keyword used in anonymous inner class

Introduction

What is the output of the following code:

public class Main
{
   public final int value = 4;
   public void doIt()
   {/*w w w.  j av a2 s .  co  m*/
      int value = 6;
      Runnable r = new Runnable(){
         public final int value = 5;
         public void run(){
            int value = 10;
            System.out.println(this.value);
         }
      };
      r.run(); 
   }
   public static void main(String...args)
   {       
      Main m = new Main();
      m.doIt();
   }
}


5



PreviousNext

Related