Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes One Confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "One Confusion" Watch "One Confusion" New topic
Author

One Confusion

Ahmad Mudassir
Greenhorn

Joined: Oct 16, 2000
Posts: 10
hi every one !
Some words about casting that you can cast any primitive to any other primitive type except boolean.(from higher to lower capacity otherwise from lower to higher implicit cast is done)
And with objects you can assign reference of an object to any other object with casting(subclass object reference to superclass object reference or to an interface which is implemented by that class is done through implicit cast).
But what in the case of Wrapper classes they can not be cast to each other why?
is because they are final. so final class object's references can not be casted.
Any one can solve this problem
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
Hi Ahmad,
you've answered your own quesion in away.
Wrapper classes do not participate in parent child relationship.
mean Integer is not extended from Short and vice versa and so on.
although most of them are derived from class Number.and henceforth are sibling classes.
but casting among siblings in not allowed in java.

regards
deekasha
Ahmad Mudassir
Greenhorn

Joined: Oct 16, 2000
Posts: 10
Thanx deekasha for your clarity
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One Confusion