Upload files to "OOP/Java/Lab/Week10"

This commit is contained in:
Aadit Agrawal 2024-10-14 02:40:35 +05:30
parent 2b9a21ac62
commit 22f306573d
5 changed files with 160 additions and 0 deletions

View file

@ -0,0 +1,21 @@
import java.util.Scanner;
public class negativearr {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n;
System.out.println("Enter the number of elements");
n = sc.nextInt();
try{
int array[] = new int[n];
System.out.println("Enter the elments");
for (int i = 0; i < n; i++) {
array[i] = sc.nextInt();
}
}catch(NegativeArraySizeException e){
System.out.println("Error:"+e.toString());
}
}
}