This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Arraylist gives IndexOutOfBoundsException

 
Ranch Hand
Posts: 207
3
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see what is going on in this Exception->


If going to negative index giving AIOOBoundsException but if going to Positive index greater then actual size then giving IndexOutOfBoundsException. Why??
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll find an excellent explanation in this topic.
 
O Shea
Ranch Hand
Posts: 207
3
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Means if we give any greater index (probably >0) then it gives IOOBExcepn but if we give negative then it gives AIOOBExcepn.
Am I Right?
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No! It is implementation dependent. The only guarantee: if you provide an invalid index, you'll get an IndexOutOfBoundsException (including any of its subclasses).
 
O Shea
Ranch Hand
Posts: 207
3
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much
 
My, my, aren't you a big fella. Here, have a tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!