Results 1 to 3 of 3
  1. #1
    Vampiricx3 is offline Member
    Join Date
    Feb 2012
    Posts
    31
    Rep Power
    0

    Default How to use ArrayList's.

    How to instantiate an ArrayList.
    Java Code:
    ArrayList<String> myArray = new ArrayList<String>();
    How to add objects to the ArrayList.
    Java Code:
    myArray.add("Hello", "Goodbye", "Sayonara");
    Printing out ArrayList objects.
    Java Code:
    for(int i = 0; i < myArray.size(); i++) {
         System.out.println(myArray(i));
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: How to use ArrayList's.

    Quote Originally Posted by Vampiricx3 View Post
    How to instantiate an ArrayList.
    Java Code:
    ArrayList<String> myArray = new ArrayList<String>();
    How to add objects to the ArrayList.
    Java Code:
    myArray.add("Hello", "Goodbye", "Sayonara");
    Printing out ArrayList objects.
    Java Code:
    for(int i = 0; i < myArray.size(); i++) {
         System.out.println(myArray(i));
    }
    Are you printing out correct code or are you asking a question? If correct code, you're not quite there. If a question, then please ask it.

  3. #3
    Vampiricx3 is offline Member
    Join Date
    Feb 2012
    Posts
    31
    Rep Power
    0

    Default Re: How to use ArrayList's.

    was supposed to be
    Java Code:
    System.out.println(myArray.get(i));

Similar Threads

  1. Replies: 12
    Last Post: 07-07-2011, 09:49 PM
  2. Replies: 1
    Last Post: 05-15-2011, 07:07 PM
  3. sorting arraylist based on another arraylist
    By busdude in forum New To Java
    Replies: 4
    Last Post: 02-07-2011, 12:48 PM
  4. Replies: 7
    Last Post: 11-22-2010, 02:26 PM
  5. 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
  •