This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes array store exception 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 "array store exception" Watch "array store exception" New topic
Author

array store exception

gurpreet singh
Ranch Hand

Joined: Apr 07, 2006
Posts: 38
Hello frnds,

pls explain why does
Object[] objArr = new String[10];
objArr[0] = new Long(); // compiles; fails at runtime

but
String[] objArr = new String[10];
objArr[0] = new Long(); // gives compile time exception


SCJP
Dan Polak
Ranch Hand

Joined: Nov 06, 2006
Posts: 32
Long IS A Object, but Long IS NOT A String


<a href="http://www.dantheman.pl" target="_blank" rel="nofollow">http://www.dantheman.pl</a>
 
GeeCON Prague 2014
 
subject: array store exception