Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayStoreException

 
bikasit babu
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic