File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes IndexOutOfBoundsException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "IndexOutOfBoundsException" Watch "IndexOutOfBoundsException" New topic
Author

IndexOutOfBoundsException

Mauro Trevigno
Ranch Hand

Joined: Aug 27, 2012
Posts: 39

I have a java.lang.IndexOutOfBoundsException.
I read another topic I have to add something like this: customer.add(1); But I think the index need to be my file.








Thank You!

Regards,
-M
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi,

Seems your your arraylist is empty,that is why you are getting indexoutofbound exception.Check the size of the arraylist.

Regards
Jatan
Ankit Chaudhary
Greenhorn

Joined: Sep 16, 2011
Posts: 3
Hi Mauro,
From the code snippet that you provided it seems that its trying to get 0th element from an array without checking its size.This may result in index out of bound exception if array list is empty.
You can put the check of size(it should be greater than 0) before getting element at 0th index from an array list.

Thanks and Best Regards,
Ankit
-------------------------------------------------------------------------------- --------------------------
AnkitChaudhary | ankchaudhary@infocepts.com | www.infocepts.com
-------------------------------------------------------------------------------- ---------------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IndexOutOfBoundsException
 
Similar Threads
(B&S) Error in my cache(ArrayList)
Collections.shuffle problem
File Not Found Error
Open file using thread
Reading Data from a file and extracting the data