Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

arrayList.remove()

 
aude tantot
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've an arrayList and i want to use the remove() method, but when i do it on the first or last element, it delete the second or the one before the last element, what's the matter?
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps a code snippet showing how you're indexing the ArrayList might shed some light on the problem.
Sean
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remeber that arraylist, arrays, start indexing at zero in Java. Verify that's not the problem.

Bosun
 
aude tantot
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem comes in fact from the way i pass the element to be deleted. I select it from a combobox doing MyCombo.getSelectedItem(), and it returns me a wrong element.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic