Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.NullPointerException  RSS feed

 
Zack Lock
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting an error "Exception in thread "main" java.lang.NullPointerException" at line 19. and I have no idea why. The program is to read the contents of a text file and write each line into an array of objects.
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That could only be because your "str" variable was null.
 
Zack Lock
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any suggestions for fixing that without getting too in depth? This project contains several different files and the "Accounts.txt" file reads as follows.
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without getting too in-depth, I would suggest modifying your "while" condition so that it doesn't allow the loop to be executed when str is null.
 
Zack Lock
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wow thanks, I feel like such an idiot.....I completely missed my error...Really thanks so much for your help.
 
Campbell Ritchie
Sheriff
Posts: 55292
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I presume you already know how to incorporate the null check in your while condition.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!