This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Object obj = Boolean.class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Object obj = Boolean.class" Watch "Object obj = Boolean.class" New topic

Object obj = Boolean.class

Raghu Shree
Ranch Hand

Joined: Mar 18, 2005
Posts: 143
Object obj = Boolean.class;

Could any one explain me how this statement is valid?

Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="" target="_blank" rel="nofollow">SCWCD Group</a>
Animesh Shrivastava
Ranch Hand

Joined: Jul 19, 2004
Posts: 298
Whats the problem with that,
the statement Boolean.class object of type class Class
and since Object is the super class of every object. So this has to be valid
Amit Das
Ranch Hand

Joined: Mar 05, 2005
Posts: 206
also make a note:
Boolean.class IS-A Object //true
Boolean.class IS-A Class //true
Boolean.class IS-A Boolean //false

an FYI

Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
To continue the theme:
Boolean.class IS-A Class<Boolean>
Boolean.class IS-A Class<? extends Boolean>
Boolean.class IS-A Class<? extends Comparable<Boolean>>
Boolean.class IS-A Class<? extends>
Boolean.class IS-A Class<? extends Object> (redundant, see below)
Boolean.class IS-A Class<? super Boolean>
Boolean.class IS-A Class<?>
X<? extends Object> is redundancy and should be replaced with X<?> (for all X)
[ April 27, 2005: Message edited by: Tony Morris ]

Tony Morris
Java Q&A (FAQ, Trivia)
Don't get me started about those stupid light bulbs.
subject: Object obj = Boolean.class
Similar Threads
I know local objects are thread safe. But why not obj here too?
deserialization and casting
primitive types not castable as lang.Object
Exception with Constructor.newInstance(Object... initargs)