Results 1 to 3 of 3
  1. #1
    kingkongjaffa is offline Member
    Join Date
    Aug 2011
    Posts
    6
    Rep Power
    0

    Default Stuck with a little aspect of the array list

    so the scenario is an array list with elements that has been populated using the .add()
    method, containing 3 variables ID fname and sname.

    I can run a search using an if statement
    with condition of having one of the variables equal to the search criteria, which prints
    me back the search results correctly

    I can refine to one search result and at that point the refined result is the details that
    are the current value of the variables,

    but I'm having an issue with the editing
    function I can choose to change the
    value of the variable but when it comes
    to using the .set() method I cannot
    locate the index to overwrite the data to.

    any ideas on how to find the index of an arraylist element. the indexOf method
    hasn't worked.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,332
    Rep Power
    25

    Default Re: Stuck with a little aspect of the array list

    You might not have to change the contents of the arraylist by using set. If you get a reference to an object in the arraylist, you can use its methods to change the object's contents. The updated version will stay in the arraylist if you do not remove it.

    If this doesn't work, please make and post a small program that demonstrates your problem.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,458
    Blog Entries
    7
    Rep Power
    20

    Default Re: Stuck with a little aspect of the array list

    Quote Originally Posted by kingkongjaffa View Post
    the indexOf method hasn't worked.
    If that didn't work the equals( ... ) method and hashCode() method of the elements in your List are not correctly implemented.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Linked List, Array List time complexity
    By Rick99771977 in forum New To Java
    Replies: 4
    Last Post: 08-18-2011, 05:37 AM
  2. Replies: 2
    Last Post: 09-06-2010, 01:03 AM
  3. Now stuck with inserting data into a list.
    By mainy in forum New To Java
    Replies: 2
    Last Post: 07-31-2009, 03:49 PM
  4. using an Array list
    By toad in forum New To Java
    Replies: 1
    Last Post: 11-18-2007, 09:08 PM

Tags for this Thread

Posting Permissions

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