• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread

 
mike hew
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I fix the three C's problem, ok I can't spell, lol.

Now I have no error's but when I excute the program I get this:

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





Big Bank: Monthly Checking Account Activity


----------- Account ----------- Beginning With- Ending Over- Credit Cd

Name Id Type Balance + Deposit - drawal - Fee = Balance draft Advance

Exception in thread "main" java.lang.NullPointerException

at CheckingAccountsTest.handleAccount(CheckingAccountsTest.java :103)

at CheckingAccountsTest.main(CheckingAccountsTest.java:56)


G:\ ~1>




[ November 16, 2006: Message edited by: mike hew ]
[ November 16, 2006: Message edited by: mike hew ]
 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A NullPointerException here:

means that one or possibly more of the following is true:
- currentAccount == null
- currentAccount.getAccountId() == null
- myFields == null

I suggest the following code:


and see where the null is.

I don't really see what the point of the line is, though - it is basically saying either "true" or "false", and there is no action taken based on whether it is true or false.

Coult it be that you are trying to set accountId (since it is likely null) to a value stored in myFields? In which case the code should be

[ November 17, 2006: Message edited by: �dne Brunborg ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic