I'm having a problem with my program. Currently, I'm making a billing account system. Basically, I've got a great deal of the system up and running. As a feature, rather than having a user remember their position in an array, a user could carry out actions for their account by entering their account number. So, in other words, they would be prompted to enter an account number and any actions are attributed to that account.
Here is the code I have so far:
intEntry = input.nextInt();
for (count = 0; count <= ACCLIMIT; count++)
{
if (intEntry == NewAccount[count].getAccRefNo() )
{
intSelectedEntry = count;
}//end of if statement
else
{
System.out.println("Invalid ID!");
}//end of else statement
}//end of loop
System.out.println("*******Please enter the amount you wish to deposit*******") ;
valDeposit = getBalanceValidation();
parDepositAmount = Double.valueOf(valDeposit).doubleValue ();
NewAccount[intSelectedEntry].deposit(parDepositAmount);
When I run it, it crashes once I enter the ID number intEntry
. It says the error is in the line of the if statement criteria, if that helps.
Please be aware I'm really new to Java, and I'd really appreciate this help explained in a simple way. (Thanks!)
Here is the error message:
Exception in thread "main" java.lang.NullPointerException
at pkgGasAccount.UsingBusinessAccount.main(UsingBusinessAccount.java:106)
Java Result: 1
Line 106 is the first line of the if statement (the criteria)