It's not a secret anymore!
The moose likes Beginning Java and the fly likes Array List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array List" Watch "Array List" New topic

Array List

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Hello world,
I just wanted to know this. I have an array list of objects of the same class type. For example item details of a bill. Now i want to delete the 5th element(10elements are there). If I delete the 5th element what will happen to the element numbers of the array list. I mean the 6th element will it become the 5th element in the array list after deleting, the 5th element.
Hope you got what I mean.

SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

You are correct. If you remove the fifth element, then the sixth element becomes the fifth element, the seventh becomes the sixth, etc. In addition, the size of the array becomes 9.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Thanks for the reply. I just wanted to make sure what I had in my mind correct.
I agree. Here's the link:
subject: Array List
jQuery in Action, 3rd edition