• Post Reply Bookmark Topic Watch Topic
  • New Topic

Arrays.sort() NullPointerException  RSS feed

 
Victor Thomas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I'm getting this error and really don't see where I am erring. A previous version I have runs fine in eclipse and from the commandline, however this doesn't :


The class file is :

Other than removing some comments and debugging System. out() statements, this is the same file that still works in the earlier incarnation. Any help, or quicker eyes, would be welcomed. Thanks.

V.
 
Stephan van Hulst
Saloon Keeper
Posts: 7992
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You get a NullPointerException because something is null that shouldn't be. It happens while sorting the array, so perhaps one of the array elements is null. Take a look at how you assign values to your array.
 
Rob Camick
Ranch Hand
Posts: 2828
15
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Looks to me like you are missing an entry.
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:Looks to me like you are missing an entry.


+1.
Its throwing a NullPointer in compareTo. So the missing element might be he culprit.
 
Victor Thomas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stephan,Rob, and Mohamed! I am embarrassed to say, I totally missed it... Apparently I need to take a break and go do some suburi. Again, thanks so much for your assistance. Take care.

V.
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Victor Thomas wrote:Thanks Stephan,Rob, and Mohamed! I am embarrassed to say, I totally missed it... Apparently I need to take a break and go do some suburi. Again, thanks so much for your assistance. Take care.

V.


And welcome to JavaRanch!!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!