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

ArrayIndexOutOfBoundsException

 
kevinn lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It could be that exception objects override the toString() method which gets called whenever any object is printed.
 
kevinn lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yup I was just about to post that..

I learnt something today !!!


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic