NEP -AI-LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

PART B

PROGRAM B1 . . .
DOWNLOAD PDF - AI LAB MANUAL

 
  
 
 
 
 
 
/* B1:
Program to catch Negative Array Size Exception. This exception is caused when the
array is initialized to negative values.*/

class programb1

{

public static void main(String as[])

{

        int arrSize = -8;
        try {

            int[] myArray = new int[arrSize];

        } catch (NegativeArraySizeException ex) {

            System.out.println("Can't create array of negative size");
        }

}
}