-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqb103.java
More file actions
25 lines (22 loc) · 752 Bytes
/
qb103.java
File metadata and controls
25 lines (22 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//QB-103
//Give Command line argument
class qb103 {
public static void main(String[] args) {
if (args.length == 0) {
throw new NumberFormatException("Length should not be Zero Enter any element. ");
}
for (String arg : args) {
try {
int num = Integer.parseInt(arg);
if (num < 0) {
throw new IllegalArgumentException("Number should not be Negative");
}
} catch (NumberFormatException e) {
System.out.println(e.getMessage());
} catch (IllegalArgumentException e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
}
//java qb103 1 -2