| 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
|
|
|
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
|
|
Looks to me like you are missing an entry.
|
 |
Mohamed Sanaulla
Bartender
Joined: Sep 08, 2007
Posts: 2929
|
|
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
|
|
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!!
|
 |
 |
|
|
subject: Arrays.sort() NullPointerException
|
|
|