Computer Science Canada

get and index and remove it in an ArrayList

Author:  blackhawk_prince [ Sun May 18, 2008 8:49 am ]
Post subject:  get and index and remove it in an ArrayList

simple question, is there a method to get an index and remove it form an arraylist?

Author:  syntax_error [ Sun May 18, 2008 10:05 am ]
Post subject:  RE:get and index and remove it in an ArrayList

a.remove(i)

is that what you are looking for?

Author:  Reality Check [ Sun May 18, 2008 3:13 pm ]
Post subject:  Re: get and index and remove it in an ArrayList

Well what are you trying to get? Is it a specific Integer Object or a String? You can use the indexOf method to locate a specific word or number and then once you have gotten the index you can remove it.

code:

a.add ("the");
a.add ("here");
a.add ("ka");
a.add ("array");

a.remove (a.indexOf ("here"));


This removes the "here" object from your list. You should be using the java help for a simple question like this though...


: