This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes ArrayStoreException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ArrayStoreException" Watch "ArrayStoreException" New topic
Author

ArrayStoreException

bikasit babu
Greenhorn

Joined: Mar 29, 2012
Posts: 28
What is ArrayStoreException ?
class SuperArry
{

}
public class Array extends SuperArry{
public static void main(String[] args) {
SuperArry[] ar = new Array[3];
ar[0] = new Array();
ar[1] = new SuperArry();
ar[2] = new Array();
}

}
While Running this program why getting ArrayStoreException at line 10?
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Did you check the API for that exception?

Thrown to indicate that an attempt has been made to store the wrong type of object into an array of objects. For example, the following code generates an ArrayStoreException:
Object x[] = new String[3];
x[0] = new Integer(0);


Pretty clear, isn't it?


The quieter you are, the more you are able to hear.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayStoreException
 
Similar Threads
why it does print "[ ]" for the ArrayList where as it is some memory value for array?
gc in array
exception in static initialiser
Help coding
ArrayStoreException - Inquition doubt