wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes NullpointerException in Arrays.sort() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "NullpointerException in Arrays.sort()" Watch "NullpointerException in Arrays.sort()" New topic
Author

NullpointerException in Arrays.sort()

amarkirt saroay
Ranch Hand

Joined: Mar 16, 2008
Posts: 167

Why it gives runtime exception of Nullpointer in line 1?


SCJP-75%
SCWCD-82%
Srividhya Kiran
Ranch Hand

Joined: Feb 17, 2008
Posts: 166
Hi

When you create Integer[] y=new Integer[10];

By default, null values will be assigned to Integer Array Object 'y'.

Therefore sorting the array with null values returns in NullPointerException

Srividhya
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Hint:


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullpointerException in Arrays.sort()
 
Similar Threads
LinkedList problem
Collection.toArray() method
Autoboxing / unboxing
list and array
casting doubt