• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Exception "main" java

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok the help with Brunborg, I was able to get this far.
But I can't seem to figure out how to resolve it?
at the bottom is the Psuedo code for these 2 parts.

Big Bank: Monthly Checking Account Activity


currentAccount = null, null
currentAccount.getAccountId() = null
myFields = [Ljava.lang.String;@1e0be38
myFields[indexForAccountId] = 0100C
Exception
in thread "main" java lang Null Pointer Exception
at CheckingAccountsTest.handleAccount(CheckingAccountsTest.java:107)
at CheckingAccountsTest.main(CheckingAccountsTest.java:56)

G:\NEW9~1>



A-1-2-07)Get 1st record from CSV file using method readARecord: MyCsvFile class: myFile.readARecord()
A-1-2-08)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)line 56CALL 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
This private static method has no return value, and has three parameters: currentAccount of type CheckingAccount, myFile of type MyCsvFile and myFields of type String array.
A-1-3-01)CALL method currentAcccount.getBalance and ADD its return value to sumOfBeginningBalances
A-1-3-02)CALL method printBeginningBalance with the following argument list: currentAccount
A-1-3-03)CALL method myFile.readARecord, which reads the 1st record after the Balance record (a deposit or withdrawal) for the current customer
A-1-3-04)CALL method myFile.getCsvRecordFieldArray and ASSIGN its return value to myFields, a String array. This makes the values from the
A-1-3-05)fields in the record just read available for access as elements in the myFields string array
A-1-3-06)WHILE (myFile.getEofFound()IS FALSE AND line 107currentAccount.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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Exception
in thread "main" java lang Null Pointer Exception
at CheckingAccountsTest.handleAccount(CheckingAccountsTest.java:107)
at CheckingAccountsTest.main(CheckingAccountsTest.java:56)



Look at the error message. It says there is an exception in line 107 of the file CheckingAccountsTest.java. So, now look at that source file, line 107. Something is null there that is not supposed to be null. Find out why it is null.
 
reply
    Bookmark Topic Watch Topic
  • New Topic