Forums Register Login

IndexOutOfBoundsException

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Hi,

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

Regards
Jatan
+Pie Number of slices to send: Send
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
-------------------------------------------------------------------------------- ---------------------------
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 966 times.
Similar Threads
Open file using thread
Reading Data from a file and extracting the data
Collections.shuffle problem
(B&S) Error in my cache(ArrayList)
File Not Found Error
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:14:54.