aspose file tools*
The moose likes Beginning Java and the fly likes getMessage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getMessage" Watch "getMessage" New topic
Author

getMessage

abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130




/*

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

Joined: Oct 02, 2003
Posts: 11422
    
  16

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?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
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

Joined: Aug 16, 2005
Posts: 14273
    
  21

Try changing line 13 to:

instead of just printing the information message of the exception.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
wood burning stoves
 
subject: getMessage