Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How do I return an array list?

Threaded View

  1. #1
    Member
    Join Date
    Jul 2012
    Posts
    42
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question How do I return an array list?

    Ok, so to ensure everything is working ok, i want to be able to return my data from my array list. The code is below and if anyone can tell me how i could return the data (preferabley by printing it. Thanks

    import java.util.ArrayList;
     
    public class ContactList
    {
        private ArrayList<Contact> contactList;
        private ArrayList<Contact> aContact;
        private String contactType;
     
        public ContactList()
        {
     
            contactList = new ArrayList<>();
            aContact = new ArrayList<Contact>();
            ArrayList<Contact> contactList = new ArrayList<Contact>();
        }
         public void addPersonalContact(String fName, String sName, String street, String town, String partOnePC, String partTwoPC, String phonenumberEmail)
        {
            contactList.add(new AddPersonalContact(fName, sName, street, town, partOnePC, partTwoPC, phonenumberEmail));
     
     
        }
     
     
     
        //public void addBusinessContact(String fName, String sName, String street, String town, String partOnePC, String partTwoPC, String phonenumberEmail)
        //{
          //  contactType = "Business";
            //aContact.add(new Contact(fName, sName, street, town, partOnePC, partTwoPC, phonenumberEmail));
     
     
     
        //}
     
     
     
    }
    Last edited by 93tomh; July 26th, 2012 at 12:12 AM.


Similar Threads

  1. Array List of Array Lists working for first item but not for second.
    By javapenguin in forum Collections and Generics
    Replies: 6
    Last Post: February 15th, 2012, 05:12 PM
  2. method to return the position of the smallest item in an array
    By izzahmed in forum Java Theory & Questions
    Replies: 5
    Last Post: November 4th, 2011, 04:18 AM
  3. Doubling The Array Size And Randomizing Array Return
    By Pingu00 in forum What's Wrong With My Code?
    Replies: 18
    Last Post: June 27th, 2011, 10:50 AM
  4. Search for number in array and return index
    By Kevinius in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 24th, 2011, 12:00 AM
  5. Error of missing return statement while implementing Array
    By MS_Dark in forum Collections and Generics
    Replies: 1
    Last Post: December 10th, 2008, 03:18 PM