Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 get and index and remove it in an ArrayList
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
blackhawk_prince




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
syntax_error




PostPosted: 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?
Reality Check




PostPosted: 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...
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: