Originally posted by Surasak Leenapongpanit:
Hi Chandra,
Why does it compile and return 2?
Hi,
When I compile the Test.java, the result is following:
I used javap to see what happened behind:
For A.class
For B.class:
Findings:
You should not (I wont say can't because code compiles with warning ) override a method that is with varagrs parameter with array and vice versa is also true. It gives warning.
Actually all the var-args are converted with array parameter. Compiler does so, that is why the code compiles fine. Overridden version of the method is
called polymorphically (run time decision).