All About ArrayStoreException in Java

ArrayStoreException is thrown out of a program to indicate that an attempt to store the wrong type of object into an array of different type of objects.
The structure of the class as follows:

public class java.lang.ArrayStoreException extends java.lang.RuntimeException{
public ArrayStoreException ();
//constructs an empty ArrayStoreException object that is an object with no message specified.
public ArrayStoreException (String message);
//constructs an ArrayStoreException object with the message specified.

This exception is occurs when one tries to store a value in an array of an incompatible class or type.

void wrongArrayStore()
int storeArray=new int[15];
boolean booArray=new boolean[5];
Output of the code will be an ArrayStoreException.
All About ArrayStoreException in Java All About ArrayStoreException in Java Reviewed by Animesh Chatterjee on September 17, 2018 Rating: 5

No comments:

Powered by Blogger.