Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't double.class equal java.lang.Double.class?

Since the primitive double is represented with the java.lang.Double class, shouldn't double.class equal java.lang.Double.class? (This of course also happens on other primitive types too)

System.out.println(double.class == Double.class);

Output:

Result: false
like image 351
Enes Sadık Özbek Avatar asked Jul 31 '15 21:07

Enes Sadık Özbek


1 Answers

Double.class is the class object corresponding to the wrapper type Double. double is actually not a class, but double.class is the object used in reflection to indicate that an argument or return type has primitive type double.

like image 161
Paul Boddington Avatar answered Sep 17 '22 23:09

Paul Boddington