I want to write this little program which should make a simple calculation while taking input for one variable. Here's the code:
public class DFact {
public static void main(String[] args) {
int n;
int df;
int i;
n = Integer.parseInt(args[0]);
df = 1;
i = n;
while(i > 0) {
df = df * i;
i = i - 2;
}
System.out.println(df);
}
}
For this programm I am getting the following message:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at DFact.main(DFact.java:9)