aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
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>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: array store exception