wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Arrays.sort() NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Arrays.sort() NullPointerException" Watch "Arrays.sort() NullPointerException" New topic
Author

Arrays.sort() NullPointerException

Victor Thomas
Greenhorn

Joined: Oct 31, 2010
Posts: 9
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
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

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

Joined: Jun 13, 2009
Posts: 2200
    
    7


Looks to me like you are missing an entry.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

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.


Mohamed Sanaulla | My Blog
Victor Thomas
Greenhorn

Joined: Oct 31, 2010
Posts: 9
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
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

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!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arrays.sort() NullPointerException