[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

LinkedList

Asked by alepru in Java Programming Language

Hello. I need help writing a program that reads in a series of first names and stores them in a LinkedList. Do not store duplicate names. Allow the user to search for a first name.
This is what i have so far. Thank you.


import java.io.*;
import java.util.ListIterator;
import java.util.LinkedList;

public class llist
{
      public static void main(String[] args)throws IOException
      {
            BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
            //create LinkedList object
            LinkedList lList = new LinkedList();
            String names="";
            String response="";

            System.out.print("");
            System.out.print("Input a name:");
            names = dataIn.readLine();

            System.out.print("Would you like to enter another name? Enter yes or press any key to exit.");
            response = dataIn.readLine();
            if (response != null)
            {
                  response = response.toUpperCase();
            }

            while (response != null && response.equals("YES"))
            {
                  //add elements to LinkedList
                  lList.add(names);

                  System.out.print("Input name:");
                  names = dataIn.readLine();
                  System.out.print("Would you like to enter another name? Enter yes or press any key to exit.");
                  response = dataIn.readLine();
                  if (response != null)
                  {
                        response = response.toUpperCase();
                  }
            }

            lList.add(names);

            ListIterator itr = lList.listIterator();

            System.out.println("");
            System.out.println("This is the list of names entered:");

            while(itr.hasNext())
            {
                  System.out.println(itr.next());
            }

            System.out.println("");

      }

}

[+][-]11/03/09 10:10 PM, ID: 25736825Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 10:14 PM, ID: 25736845Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 10:15 PM, ID: 25736847Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 10:42 PM, ID: 25736960Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 12:04 AM, ID: 25737263Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 04:11 PM, ID: 25745578Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 11:37 PM, ID: 25747408Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 01:42 AM, ID: 25747896Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 03:06 AM, ID: 25748282Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 08:47 AM, ID: 25751349Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 08:50 AM, ID: 25751378Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 09:56 AM, ID: 25752055Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 09:58 AM, ID: 25752072Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 12:41 PM, ID: 25753773Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/20/09 12:50 PM, ID: 25874420Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625