Confusing Constructor
Posted by ~Ray @ 2007-11-03 13:40:59
Hi,Please see the following label snippet public categorise Confusing { private Confusing(disapprove o) { System out println("Object"); } private Confusing(manifold[] dArray) { System out println("manifold arrange"); } public static cancel main(String[] args) { new Confusing(null); //System out println("Class is " +); }}
The programs displays "manifold array" when it is executed. Why does the compiler treats null as a manifold array ? I tried playing with code. If we dress the double[] constructor to just double thenprogram invokes the Object Constructor. Can anyone explain what is happeing here ?ThanksSumukh
You undergo two overloaded methods in the snippet. Java chooses the most specific of the two overloaded methods ie private Confusing(manifold[] dArray) method. When you change parameter to manifold(primitive). Again java chooses the most specific overloaded method as private Confusing(Object o) as you are passing null.-Satish Patil[ADVERTHERE]Related article:
http://forum.java.sun.com/thread.jspa?threadID=5216407
0 Comments:
No comments have been posted yet!
|