Type Here to Get Search Results !

Write a JAVA program for example of try and catch block. In this check whether the given array size is negative or not.

 class NegTest

{

public static void main(String a[])

{

try


JAVA PROGRAMMING LAB MANUAL (R13)

{

int a1[] = new int[-2];

System.out.println("first element : "+a1[0]);

}

catch(NegativeArraySizeException n)

{

System.out.println(" Generated Exception is : " + n);

}

System.out.println(" After the try block");

}

}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Featured post

M

M