Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getMessage

 
abhay jain
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




/*

output

6

this number always relevent to index number here a[6]

why ???


so far i know that ...
getMessage():

Returns the error message string of this throwable object.

Returns:
the error message string of this Throwable object if it was created with an error

message string; or null if it was created with no error message.

.. but still don't understand why ??? it shows that index 6 (in that case )


*/
 
fred rosenberger
lowercase baba
Bartender
Posts: 12202
35
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because your array only has 5 elements. there is no a[6].

And since you know you have an ArrayIndexOutOfBoundsException, the only other thing you might need to know is what index you are trying to access.

What would you expect it to say?
 
abhay jain
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:because your array only has 5 elements. there is no a[6].

And since you know you have an ArrayIndexOutOfBoundsException, the only other thing you might need to know is what index you are trying to access.

What would you expect it to say?



oh ! now i understand .. thanks
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15490
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try changing line 13 to:

instead of just printing the information message of the exception.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic