• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null pointer exception trouble

 
Jason Rod
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that an array reference is null until you instantiate it.
[ May 17, 2006: Message edited by: Keith Lynn ]
 
Jason Rod
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I'm new to using arrays, how would I instantiate it in this case?
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jason Rod
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh ok, got it, thanks so much
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic