class anEvent{
String number;
String dueTime;
}
public static void main(String args[]) {
int x = args.length / 2;
int y = args.length;
anEvent [] order = new anEvent [x];
for(int i=0; i<x; i++){
if(i==0){
order[i].number = args[0]; //Line(#)
order[i].dueTime = args[1];
} else if ( i % 2 == 0){
order[i].number = args[i];
order[i].dueTime = args[i];
} else if ( i % 2 != 0){
order[i].number = args[i+1];
order[i].dueTime = args[i+1];
} else if ( i == x -1){
order[i].number = args[x-1];
order[i].dueTime = args[x-1];
}
}
Java complains that a Null Pointer exceptuion is present at line # in the above snippet.
What's the matter?
ps: I know that the snippet can be cleaned up but there should be no problem at all on line #