Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Input - Null Pointer Exception  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, trying to do an assignment here for class and I'm getting stuck on this null pointer exception (line 20 of the 1st block of code on here). I know what it means but every way I go about fixing it, it's just complaining even more in the compiler.






It is complaining about the "student[numStu].setName(stuName);" line and it's making my head about to explode to why it's happening. I'm really a beginner and it's the frustrations of java getting to me haha.
 
Ranch Hand
Posts: 144
Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way to learn is to dry run your program.

 
Johnny Smiths
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Zeeshan Sheikh wrote:The best way to learn is to dry run your program.



It won't accept the line above it? "stuName = gradeFile.nextLine();"
Because basically what I'm trying to do is to set the "stuName" to the next line from the file.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!