class Outer1
{
void pop()
{
System.out.println("In Outer1");
}
}
class Anony
{
void Ano()
{
Outer1 o=new Outer1()
{// Statring brace of Anonymous subclass of Outer1
void pop()
{
System.out.println("Welcome To pop");
}
void jazz()
{
System.out.println("Welcome To Jazz");
}
}; //closing off the Anonymous class
o.pop();
//o.jazz(); will give error as "cannot resolve symbole" as Super class reference variable is not familier with the methods those are declared only in Subclass (Here Anonymous class)
}
}
public class PolymorAnonyClass
{
public static void main(
String []arg)
{
Anony a=new Anony();
a.Ano();
}
}
As in the above piece of code it's not possible to call jazz() with the superclass reference.
So how jazz() can be called?
Thank You
Deepak Bahubal