blob: cbc651eedc5ae4fe42d5a62adf8f6ab1e58f9033 (
plain)
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
26
27
28
29
|
public class Count {
public static void main(String[] args) {
if (args.length < 2) {
System.err.println("[ERROR] Type two integers as arguments.");
System.exit(1);
}
int start = 0;
int end = 0;
try {
start = Integer.parseInt(args[0]);
end = Integer.parseInt(args[1]);
} catch(NumberFormatException nfe) {
System.err.println("[ERROR] You didn't provide integer arguments.");
//System.err.println("Details: " + nfe.getMessage());
System.exit(2);
}
if(start > end) {
System.err.println("[ERROR] Start is greater than end.");
System.exit(3);
}
for(int i = start; i <= end; i++) {
System.out.println(i);
}
}
}
|