Java 26 - try andcatch - negative array
Sun Nov 26 2023 17:11:09 GMT+0000 (Coordinated Universal Time)
Saved by
@Java
import java.util.*;
class Lab26
{
public static void main(String args[])
{
Scanner x=new Scanner(System.in);
System.out.print("enter size=");
int size=x.nextInt();
try
{
int a[]=new int[size];
}
catch(Exception e)
{
System.out.println(e);
System.out.println("array size is negative");
System.exit(0);
}
finally
{
System.out.println("array size is positive");
}
} }
content_copyCOPY
Comments