aspose file tools*
The moose likes Beginning Java and the fly likes Null pointer exception trouble Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Null pointer exception trouble" Watch "Null pointer exception trouble" New topic
Author

Null pointer exception trouble

Jason Rod
Greenhorn

Joined: Apr 13, 2006
Posts: 14
I am working on a program that will grade tests and return the test scores, the average, highest, and lowest scores, and will sort the scores from highest to lowest. The program allows the user to input answers for only one of the students, the rest of the student answers are hard-coded. I am having trouble with a null pointer exception on the line that says:

char studAns[][] = new char[][]

I am also unsure about the sorting method that I used, I have been having problems trying to find a simple sorting algorithm that will allow the data in the array to maintain it's same index number while being sorted.

here is the code



[ May 17, 2006: Message edited by: Jason Rod ]

[ May 17, 2006: Message edited by: Jason Rod ]

[ May 17, 2006: Message edited by: Jason Rod ]
[ May 17, 2006: Message edited by: Jason Rod ]
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Remember that an array reference is null until you instantiate it.
[ May 17, 2006: Message edited by: Keith Lynn ]
Jason Rod
Greenhorn

Joined: Apr 13, 2006
Posts: 14
Sorry, I'm new to using arrays, how would I instantiate it in this case?
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
Jason Rod : Sorry, I'm new to using arrays, how would I instantiate it in this case?

Something like this:


Also remember that arrays in Java are 0 based, so an array with length = 10 will have indices 0 - 9.


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Jason Rod
Greenhorn

Joined: Apr 13, 2006
Posts: 14
oh ok, got it, thanks so much
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257

Please dont forget to post the entery point and order of the calls, next time. The program behavior depends on the order of the method calls.

Thank you.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Null pointer exception trouble