Free CoreJava Programs Source codes | Examples | Video Tutorials Download

Wednesday, January 21, 2009

NegativeArraySizeException Program

/**

* Generate negativearraysizeexception.

*

*

*/

public class NegativeSize {

/**

* generate negative array size exception and caught it and display it

*/

public static void generateException() {

try {

int[] intArray = new int[-1];

} catch (NegativeArraySizeException e) {

System.out.println("Error : NegativeArraySizeException");

e.printStackTrace();

}

}

/**

* execution begin from here

*

* @param args

* commandline argument

*/

public static void main(String[] args) {

generateException();

}

}

No comments:

Post a Comment

Followers