3

Possible Duplicate:
Why are only final variables accessible in anonymous class?

private void printPrize(final int f,final int f1){  
        System.out.println("f  "+ f+" f1 "+ f1);  
        TT t= new TT(){  

            @Override  
            public int count() {  
               return calculateCount(f, f1);  
            }  

        };  
        t.getCount();  
    }  

i force to mark f and f1 as final to access them in the anonymous class. Why is this?

Thanks

Community
  • 1
  • 1
Milan Mendpara
  • 3,091
  • 4
  • 40
  • 60
  • http://stackoverflow.com/questions/4732544/why-are-only-final-variables-accessible-in-anonymous-class – Kent Feb 02 '12 at 17:06
  • 1
    Doesn't anyone know how to use search engines anymore? This was in the top 3 search results on google. I would downvote this question, but I don't have the privileges for that yet. :D – eternaln00b Feb 02 '12 at 17:07

0 Answers0