File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

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

Dan Polak
Ranch Hand

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

<a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: array store exception
jQuery in Action, 3rd edition