Program to catch Negative Array Size Exception. This exception is caused when the array size is initialized to negative values.*/ import java.util.Scanner; public class Negative_Array { public static void main(String[] args) { Scanner in=new Scanner(System.in); try { System.out.println("Enter array size:"); int n=in.nextInt(); int arr[]=new int[n]; //if n<0, NegativeArraySizeException is raised System.out.println("Array created."); System.out.println("Array length: "+arr.length); } catch(NegativeArraySizeException e) { System.out.println("You are trying to declare an array with negativsize:"+e); } System.out.println("Continuing execution"); } }