wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes ArrayIndexOutOfBoundsException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayIndexOutOfBoundsException" Watch "ArrayIndexOutOfBoundsException" New topic
Author

ArrayIndexOutOfBoundsException

kevinn lee
Ranch Hand

Joined: Feb 15, 2010
Posts: 87



what is the meaning of 2 in "java.lang.ArrayIndexOutOfBoundsException: 2" ?
in line //3 if some other object is given as the argument(new Q11()) the out put is object name@memory address.when a object of type exception is given the output changes to what is given above.Is it a special overloaded method of System.out.print()?
thanks
Yogesh Gnanapraksam
Ranch Hand

Joined: Dec 17, 2009
Posts: 133
what is the meaning of 2 in "java.lang.ArrayIndexOutOfBoundsException: 2" ?


It means index 2 does not exist . Just try changing int y=x[3] and see what you get. Array Indexing starts from 0 ,so for the integer array X ,only indexes 0 and 1 are available.


I do not have a correct answer to your second question.

Thanks
Yogi



kevinn lee
Ranch Hand

Joined: Feb 15, 2010
Posts: 87
Yogesh Gnanapraksam wrote:
what is the meaning of 2 in "java.lang.ArrayIndexOutOfBoundsException: 2" ?


It means index 2 does not exist . Just try changing int y=x[3] and see what you get. Array Indexing starts from 0 ,so for the integer array X ,only indexes 0 and 1 are available.


I do not have a correct answer to your second question.

Thanks
Yogi




thanks yogi
Yogesh Gnanapraksam
Ranch Hand

Joined: Dec 17, 2009
Posts: 133
It could be that exception objects override the toString() method which gets called whenever any object is printed.
kevinn lee
Ranch Hand

Joined: Feb 15, 2010
Posts: 87
Yogesh Gnanapraksam wrote:It could be that exception objects override the toString() method which gets called whenever any object is printed.

yeah I searched for it.well its throwable that overrides toString() and Exception inherits it.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Throwable.html#toString%28%29
thanks
Yogesh Gnanapraksam
Ranch Hand

Joined: Dec 17, 2009
Posts: 133
yup I was just about to post that..

I learnt something today !!!


 
Consider Paul's rocket mass heater.
 
subject: ArrayIndexOutOfBoundsException
 
Similar Threads
q from sun's epractice exam
tip: return in a catch block
? Operator
SCJP 5.0 Objective 1.3 - two questions
K&B , Chap1 Q11