I'm not sure about what you're trying to ask. double's class is double, and Double's class is Double. But the TYPE member/variable of the class Double is of type double (the primitive one). Another way to think about it is this: TYPE is just a static member, meaning it's a variable belonging to the class Double. It could be called BILLYBOB or NOTHING or MYVARIABLE. That variable is being used to store a Class object representing the primitive double (the same thing you get when you call double.class and get a Class object back from that).
Joanne said, "... double.class appears to be dereferencing a primitive type."
Absolutely right! The issue here is reflection, an extremely nifty feature of Java that is used extensively by the engines that run EnterpriseJavaBeans and the rest of e-commerce.
The mechanism requires a way to programatically represent the argument list of a method. This is done with an array of instances of the Class class. So given these methods:
The arg list of m1 is represented by an array containing Double.class, String.class, and Thread.class. But how do you represent that first arg of m2? The inventors of Java created a class that represents the double primitive type (and also one for int, byt, and the other primitives). You and I can't do much with these classes. In fact, if you're not programming with reflection they aren't any use at all. They don't have any methods or data. We refer to them as "double.class", "byte.class", etc.
Which certainly looks like dereferencing a type name as if it were an object reference.
Here's an application that uses reflection to peek inside the Double and Double classes. Copy, paste, enjoy!
Consultant to SCJP team.<br />Co-designer of SCJD exam.<br />Co-author of "Complete Java 2 Certification Study Guide".<br />Author of "Ground-Up Java".
int is a primitive class and Integer is its wrapper class... similiarly for double ....
Now Consider this.....
The output is..:
The val are double The val are double The val are class java.lang.Double
now double here is primitive and the Double is wrapper..but they both are assigned to the "Class" variables.....How is that...???
Is that both double and Double(itz already a class) are classes... Double is in java.lang package... what abt double?
[ August 12, 2005: Message edited by: A Kumar ]
double itself is NOT a class; it's a primitive. However, as mentioned above, there is an instance of the Class class that represents the primitive type for use by any frameworks that use reflection. I think the confusion here is a misunderstanding of the difference between a Class object and the type of a variable. If you can understand this, then you should be okay.