Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NullpointerException in Arrays.sort()  RSS feed

 
amarkirt saroay
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why it gives runtime exception of Nullpointer in line 1?
 
Srividhya Kiran
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!