by, 05-24-2011 at 01:48 PM (4146 Views)
java.lang.ArrayStoreException is a runtimeException and is thrown when we try to store wrong type of object into an array of objects.
For example: Storing an Integer object in a Strign array will cause this exception.Java Code:ArrayStoreException() ArrayStoreException(String s)
Since its a runtime exception, compiler won't complain about this at compile time. It will be thrown at runtime. Solution is to store only object of supported types into an array.Java Code:Object x = new String; x = new Integer(0);
Of course, an array of type A can store objects of type B if B extends A.
Hope this helps.