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

how to retirive

 
Venkat basa
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i have an arraylist

i.e ArrayList al=new ArrayList();

al.add(1,"one");
al.add(2,"two");
.
.
.
.
.

its compile fine but when am try to retrive it,it gives outof bound exception, why we take like this,any special purpose is there..?

please help me

Thanks
Venkat
 
Rameshwar Soni
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be nice if you can post how you are trying to retrieve the elements in your code . Read this
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Venkat basa wrote:when am try to retrive it,it gives outof bound exception, why we take like this,any special purpose is there..?


The exception occurs because you're trying to access an index that is not present in the list. The purpose for the exception is--surprise--to tell you that you've tried to access something that doesn't exist.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic