0
How do you use a variable declared in an anonymous class?
Obj object = new Obj(){ public int ID = 1; }; How can you reach the ID value which is declared in the instantiation of the object instead of its own class. If that isn't possible then why am I able to write this code and get no compilation errors?
2 Answers
0
object.ID I suppose
0
No, that's not possible. But I've found a workaround for this, by extending the Obj class in the class where the object is instantiated and declaring ID inside the child class.