at CheckingAccountsTest.handleAccount(CheckingAccountsTest.java :103)
at CheckingAccountsTest.main(CheckingAccountsTest.java:56)
G:\ ~1>
The Pseudo code state's this WHILE (myFile.getEofFound() IS FALSE) A-1-2-09) DEFINE a String Array named myFields, and ASSIGN it the value myFile.getCsvRecordFieldArray() A-1-2-10) IF (myFields[indexForAccountType].equals(CheckingAccount.getAccountType())) A-1-2-11) INSTANTIATE a local variable named currentAccount of class CheckingAccount, passing the following arguments: A-1-2-12) myFields[indexForAccountId], myFields[indexForFirstName], myFields[indexForLastName], A-1-2-13) Double.parseDouble(myFields[indexForBalance]) A-1-2-14) CALL method handleAccount of this class, passing the following arguments: currentAccount, myFile, myFields A-1-2-15) ASSIGN null TO currentAccount A-1-2-16) ELSE A-1-2-17) INSTANTIATE a local variable named currentAccount of class CheckingAccountPlus, passing the following arguments: A-1-2-18) myFields[indexForAccountId], myFields[indexForFirstName], myFields[indexForLastName], A-1-2-19) Double.parseDouble(myFields[indexForBalance]) A-1-2-20) CALL method handleAccount of this class, passing the following arguments: currentAccount, myFile, myFields A-1-2-21) ASSIGN null TO currentAccount A-1-2-22) END IF A-1-2-23) END WHILE
WHILE (myFile.getEofFound() IS FALSE AND currentAccount.getAccountId().equals(myFields[indexForAccountId])) A-1-3-07) IF (myFields[indexForRecordType].equals(recordTypeForDeposit)) A-1-3-08) CALL method handleDeposit with the following argument list: currentAccount, A-1-3-09) Double.parseDouble(myFields[indexForDepositAmount] A-1-3-10) ELSE A-1-3-11) CALL method handleWithdrawal with the following argument list: currentAccount, A-1-3-12) Double.parseDouble(myFields[indexForWithdrawalAmount] A-1-3-13) END IF A-1-3-14) CALL method myFile.readARecord, which reads the next deposit or withdrawal record, if any, for this customer A-1-3-15) CALL method myFile.getCsvRecordFieldArray and ASSIGN its return value to myFields, a String array. This makes the value from the A-1-3-16) fields in the record just read available for access as elements in the myFields string array A-1-3-17) END WHILE WHILE (myFile.getEofFound() IS FALSE AND currentAccount.getAccountId().equals(myFields[indexForAccountId])) A-1-4-07) IF (myFields[indexForRecordType].equals(recordTypeForDeposit)) A-1-4-08) CALL method handleDeposit with the following argument list: currentAccount, A-1-4-09) Double.parseDouble(myFields[indexForDeposit] A-1-4-10) ELSE A-1-4-11) CALL method handleWithdrawal with the following argument list: currentAccount, A-1-4-12) Double.parseDouble(myFields[indexForWithdrawal] A-1-4-13) END IF A-1-4-14) CALL method myFile.readARecord, which reads the next deposit or withdrawal record, if any, for this customer A-1-4-15) CALL method myFile.getCsvRecordFieldArray and ASSIGN its return value to myFields, a String array. This makes the value from the A-1-4-16) fields in the record just read available for access as elements in the myFields string array A-1-4-17) END WHILE
pascal betz
Ranch Hand
Joined: Jun 19, 2001
Posts: 547
posted
0
Hi
i did neither read your code nor the pseudocode... it's just too much :-)
But did you investigate the Exception message a little further ?
at CheckingAccountsTest.handleAccount(CheckingAccountsTest.java :103)
Means that a NullPointerException (often called a NPE) occured. This happend on Line 103 of the CheckingAccountsTest.java file.
A NPE occurs when you try to invoke a method or access a field on a reference which is null:
e.g.
SO whenever you run this program and the "someCondition" holds true you'll get a NPE. Now check your code, especialy what you do on line 103 and make sure this piece of code is not executed when the reference is null OR make sure the reference is never null (depends on your program what the right solution would be)
Firstly I would say, pascalbetz have made you understand what is the Exception & what does it stand for.
As the code is very big, its difficult to figure out line #'s. Your mail error point seems to be in line 103 which is called from line 56. I believe its somewhere in myFile.readARecord() or handleAccount(currentAccount, myFile, myFields); OR String []myFields = myFile.getCsvRecordFieldArray(); - the array might not be filled properly or any index that you are accessing in if() is null. To figure out, which line is creatng the problem, write a (SOP) i.e. System.out.println("Read Record"); SOP("Gof Fields");, SOP("Created currentAccount") such message after readARecord(), getCsv...() & before calling handleAccount(). This will help you identify & also confirm which line is causing the error or is run successfully. The error can also be while creating currentAccount object.
Once you know, which line is creating NullPointerException, you may also know the reason behind that & thus solve your problem. If still, you need any help, inform us. We are here to help you out.
Trupti
Regards,
Trupti (SCJP)
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
9
posted
0
Don't post the same question in multiple forums. It wastes people's time answering it in one when it has already been answered in the other.