| Author |
Nullpointer Exception problem
|
shanaya dutt
Greenhorn
Joined: Jul 02, 2009
Posts: 23
|
|
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
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
Can you point out the line where the exception is coming. Line number 96 in your code is empty...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
shanaya dutt
Greenhorn
Joined: Jul 02, 2009
Posts: 23
|
|
|
line 97...it may occur at 100 too
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
mparr is null, because you never give it any value.
And with "it" I don't mean mparr itself but mpplot's array field.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
shanaya dutt
Greenhorn
Joined: Jul 02, 2009
Posts: 23
|
|
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
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You still never assign the array field. You create two double arrays, sure, but those are method local variables.
|
 |
shanaya dutt
Greenhorn
Joined: Jul 02, 2009
Posts: 23
|
|
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
Joined: Oct 27, 2005
Posts: 19216
|
|
shanaya dutt wrote:
Where do you give it a value? The answer: nowhere. Therefore, it will remain null.
|
 |
 |
|
|
subject: Nullpointer Exception problem
|
|
|