Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Nullpointer Exception problem

 
shanaya dutt
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the following program I get a Nullpointer exception at line 96.the program reads a large list of values from a file and puts them into an array.the file does not contain any null values.pl,ease help me with this code
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you point out the line where the exception is coming. Line number 96 in your code is empty...
 
shanaya dutt
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
line 97...it may occur at 100 too
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mparr is null, because you never give it any value.

And with "it" I don't mean mparr itself but mpplot's array field.
 
shanaya dutt
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i did the following modification but it still throws an exception.Now at mparr assignment part at line 88.where am i going wrong?

 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You still never assign the array field. You create two double arrays, sure, but those are method local variables.
 
shanaya dutt
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay!!
But then whats wrong with this code.Here i'm directly accessing the array from the mpplot class.it still throws the exception at the comparison in paint.

 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shanaya dutt wrote:

Where do you give it a value? The answer: nowhere. Therefore, it will remain null.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic