• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Code execution flow

 
Kedar Dravid
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the code below:



O/p: index=2
How is it that line 2 doesn't result in a NullPointerException, since getArray() returns null? Or is it that the NullPointerException is caught in the catch block (which does nothing), and then the value 2 from [index=2] printed?
Kindly correct me if I am wrong.

[ March 08, 2005: Message edited by: Mark Spritzler ]
[ March 08, 2005: Message edited by: Mark Spritzler ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keder, I edited your post to add the CODE tags, and made the code a bit more readable for everyone.

Good Luck

Mark
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about printing something in the catch block? Then you will be able to test your hypothesis.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic