Results 1 to 2 of 2
Thread: ArrayList and remove()
- 04-21-2011, 01:37 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 1
- Rep Power
- 0
ArrayList and remove()
In class today we were learning about ArrayLists, and I thought of something. Would appending methods to the end of a .remove() element still work? For example:
list.remove(index).exampleMethod();
Is that okay or would I have to do:
temp = list.remove(index);
temp.exampleMethod();
- 04-21-2011, 01:42 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
Try it and see! Or read the API documentation for that version of remove(). If it is documented to return something with an exampleMethod() then there is no reason why you can't call it.
(This sort of chaining method calls together can become difficult to read - as evidence look around here for people who dump reams of NetBeans layout code.)
Similar Threads
-
copying contents of an ArrayList to another ArrayList
By ankit1801 in forum New To JavaReplies: 8Last Post: 03-27-2011, 06:07 AM -
how to add Arraylist filter for a jsp page showing results from a servlet-Arraylist
By alok_sharma in forum Java ServletReplies: 7Last Post: 11-22-2010, 01:26 PM -
need help with the remove method on arrayList
By ShinTec in forum New To JavaReplies: 5Last Post: 02-16-2010, 09:38 AM -
Java Project Trouble: Searching one ArrayList with another ArrayList
By BC2210 in forum New To JavaReplies: 2Last Post: 04-21-2008, 11:43 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks