Upload files to "OOP/Java/Lab/Week10"
This commit is contained in:
parent
2b9a21ac62
commit
22f306573d
5 changed files with 160 additions and 0 deletions
21
OOP/Java/Lab/Week10/negativearr.java
Normal file
21
OOP/Java/Lab/Week10/negativearr.java
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue