Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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 Spring in Action this week in the Spring 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()