Results 1 to 2 of 2
  1. #1
    Pragz is offline Member
    Join Date
    Apr 2011
    Rep Power

    Default 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:


    Is that okay or would I have to do:

    temp = list.remove(index);

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power


    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

  1. copying contents of an ArrayList to another ArrayList
    By ankit1801 in forum New To Java
    Replies: 8
    Last Post: 03-27-2011, 07:07 AM
  2. Replies: 7
    Last Post: 11-22-2010, 02:26 PM
  3. need help with the remove method on arrayList
    By ShinTec in forum New To Java
    Replies: 5
    Last Post: 02-16-2010, 10:38 AM
  4. Replies: 2
    Last Post: 04-21-2008, 12:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts