aspose file tools
The moose likes Beginning Java and the fly likes Arrays.sort() NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 3056
    
    1

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: 1791
    
    2


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

Joined: Sep 08, 2007
Posts: 2929
    
  15

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
Bartender

Joined: Sep 08, 2007
Posts: 2929
    
  15

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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Arrays.sort() NullPointerException
 
Similar Threads
Private modifier problem
Can someone tell me why?
For loop not executing
purse
Why ClassCastException at run time