aspose file tools*
The moose likes Beginning Java and the fly likes Nullpointer Exception problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Nullpointer Exception problem" Watch "Nullpointer Exception problem" New topic
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
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

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: 19541
    
  16

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 - OCEEJBD 6
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: 19541
    
  16

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: 19541
    
  16

shanaya dutt wrote:

Where do you give it a value? The answer: nowhere. Therefore, it will remain null.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nullpointer Exception problem
 
Similar Threads
Is their a GUI app that can slice, dice ,and resassemble a JPG image on the screen?
an applet compiled but can't run because of the nullPointerException
How would i break this down into seperate metods?
Can you help me plzzz with a graph?
Problem with GUI