While doing some examples in Marcus Green's site I have encountered this one.
class Base {
int i=99;
public void amethod(){
System.out.println("Base.amethod()");
}
Base(){
amethod();
}
}
public class RType extends Base{
int i=-1;
public static void main(String argv[]){
Base b = new RType();
System.out.println(b.i);
b.amethod();
}
public void amethod(){
System.out.println("RType.amethod()");
}
}
When I ran this I thought(Even Green said) the output would be
RType.amethod
99
RType.amethod
But the output I got on my machine is
99
Base.amethod
Any clues?
vasuma
P.S: I have JDK 1.3.1. on my machine.
[This message has been edited by vasuma puljety (edited November 24, 2001).]