I have two classes:
public class ClassA {
public void method(Number n) {
System.out.println(\"ClassA: \" + n + \" \" + n.getClass());
}
}
class ClassA
{
public void method( Number n )
{
System.out.println( "ClassA: " + n + " " + n.getClass() );
}// void method( Number n )
}// class ClassA
public class ClassB
extends
ClassA
{
public void method( Integer d )
{
System.out.println( "ClassB: " + d + " " + d.getClass() );
}// void method( Integer d )
public static void main( String[] args )
{
ClassB b = new ClassB();
ClassA a = b;
a.method( new Integer( 3 )); // 1. ClassA: 3 class java.lang.Integer
b.method( new Integer( 4 )); // 2. ClassB: 4 class java.lang.Integer
b.method( new Float( 5.6 )); // 3. ClassA: 5.6 class java.lang.Float
}// void main( String[] args )
}// class ClassB