here is my code ....... plz look at carefully
class Test2
{
}
class Test1
{
void method(Test2 i)
{
System.out.prin tln("Debasis: " + i);
}
}
class AnonymousTest
{
public static void main()
{
Test1 t = new Test1();
String str = "Debasis";
t.method(new Test2(){ public String toString(){retu rn str;} });
}
}
now i get a compiler error ... the variable str needs to be declared as final
why this happens ... plz help....thanxxx xxx
class Test2
{
}
class Test1
{
void method(Test2 i)
{
System.out.prin tln("Debasis: " + i);
}
}
class AnonymousTest
{
public static void main()
{
Test1 t = new Test1();
String str = "Debasis";
t.method(new Test2(){ public String toString(){retu rn str;} });
}
}
now i get a compiler error ... the variable str needs to be declared as final
why this happens ... plz help....thanxxx xxx
Comment