473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

index out of bounds

oll3i
679 512MB
Expand|Select|Wrap|Line Numbers
  1.  @Override
  2.  public void addElements(Integer i1, Integer i2){
  3.  aL.add(i1, i2);
  4.  }
  5. }
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.ArrayList.rangeCheckForAdd(ArrayList.jav a:643)
at java.util.ArrayList.add(ArrayList.java:455)
at s4409_s4409_pr2.BagResult.addElements(BagResult.ja va:23)
at s4409_s4409_pr2.QExecUtils.c(QExecUtils.java:53)
at s4409_s4409_pr2.S4409_s4409_pr2.main(S4409_s4409_p r2.java:38)
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)
Oct 31 '13 #1
2 2168
Nepomuk
3,112 Expert 2GB
OK, when you get an exception here's a good tip: READ IT! It's saying that the index is out of bounds. That's a good hint. It says the index is 1 while the size (of the ArrayList) is 0.

Another good idea is checking the JavaDocs for what you're having problems with. For example, the ArrayList#add(int, E) function. That will tell you that an IndexOutOfBoundsException is thrown "if the index is out of range (index < 0 || index > size())". Which explains the problem and should help you to solve your situation.
Oct 31 '13 #2
oll3i
679 512MB
Thank You Thank You Thank You
Nov 1 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Eugene | last post by:
Hello all, I've been trying to figure this out for a few days now, and still have no clue what's going on... I have a few related tables in MS Access (Clients, Cars, Sales), and a datagrid,...
50
by: jacob navia | last post by:
As everybody knows, the C language lacks a way of specifying bounds checked arrays. This situation is intolerable for people that know that errors are easy to do, and putting today's powerful...
0
by: scotthutchinson | last post by:
I have a .NET Remoting object hosted in IIS6 on Windows Server 2003 (happens before and after installing SP1) at an endpoint (ASP.NET application virtual folder) named "CompanyXYZReporting". The...
4
by: Antoine | last post by:
Herfried and Cor:- I used tracing and actually tracked down the code that was causing the problem most likely. I wonder if you wanted to comment on it. Also I wonder if there is a better way...
4
by: Steph. | last post by:
I have a List view displaying data in Detail mode with several columns. How I can get the column index the user clicked on ? (when user click on an item inside the ListView, not on a column...
0
by: Beaker | last post by:
I am having some trouble with an array object and a web service I have. I have a farly simple user object public class User { private Guid myUserId; public Guid UserId { get { return...
0
by: Smokey Grindle | last post by:
This is just a wierd one... I am trying to draw the sub items in the drawitem event of the list view in owner drawn mode (because of documented W32 rendering bugs) instead of in two seperate items...
7
by: Frederick Gotham | last post by:
Over on comp.lang.c, we've been discussing the accessing of array elements via subscript indices which may appear to be out of range. In particular, accesses similar to the following: int arr; ...
125
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this...
3
by: mkol | last post by:
Hi; Please, someone help me with this code - what am I missing? Error 'Index outside of bounds..' Structure2 A as string B as single public sub structure2Init A=""
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.