When we create an anonymous class, like
Employee emp = new Employee() {
void get() {
//Some body
}
void put() {
//Some body
}
};
emp.set();
emp.get();
the object reference emp refers to the object of the above anonymous inner class. We can also create another anonymous class whose object can be referred by the same object reference, like
emp = new Employee() {
void x() {
//Some body
}
void y() {
//Some body
}
};
emp.x();
emp.y();
But is there any way of creating another object for the same anonymous class? Is it possible to create a new object for an existing anonymous class, if needed?