Alessio, You are technically correct. Nevertheless, autoboxing makes the situation more complex. By autoboxing, one is saying that int is equivalent in a parameter to Integer. Now Integer is a sub-type of Object. Therefore int is more specific than Object.
This does not hold for the earlier versions of Java, but the later ones with autoboxing start to build this type of equivalence into the language at user level if not at a formal specification level. This type of issue (I would suggest) is a consequence of Java maturing as a language. It is almost impossible for a language to mature without some parts of its specification becoming case-law instead of statute. Kind regards - AJ On 9 June 2011 18:40, Alessio Stalla <[email protected]> wrote: > On Thu, Jun 9, 2011 at 6:34 PM, Alexander Turner > <[email protected]> wrote: >> Robert, >> >> I am not sure I agree here. The vargs method is not defining the type >> of the arguments. Therefore their type is actually Object. Thus we are >> comparing int to Object. int is more specific. > > int is not more specific. int is not a subtype of Object. In Java (and > in the JVM) there is not a "top" type (that is, a type which is a > supertype of every other type). This was, I believe, a design mistake, > but we can't do anything about it. > > Alessio > > -- > You received this message because you are subscribed to the Google Groups > "JVM Languages" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/jvm-languages?hl=en. > > -- Dr Alexander J Turner http://nerds-central.blogspot.com/2008/01/about-me.html -- You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en.
