CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    1

    How do i access methods from an arraylist?

    At the moment i have an arraylist as so:

    ArrayList<Client> clients = new ArrayList<Client>();

    and I've filled this arraylist with the details of the clients themselves, including things like their name, address, salary, etc.

    I can't seem to access the methods of the Client class from the ArrayList, all I end up with is an error when i try to do so. For example, I tried to access the address details of the first client in the arraylist as so:

    clients.get(0).getAddress();

    but this just gave me an error. Can someone please tell me what im doing wrong?

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: How do i access methods from an arraylist?

    If you want help with errors, please post the full error message text and stack trace, if present.

    It also helps if you post the relevant code in full. I can't see what you added to the clients list, or what the Client code is, etc., and I don't know what the error details were. I'm not going to guess when I know you could post all that information.

    Thus the task is not so much to see what no one has yet seen, but to think what no one has yet thought about that which everybody sees...
    E. Schrodinger
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured