Solved

linked list

Posted on 2004-03-29
7
161 Views
Last Modified: 2013-12-14
how to used linked list in java.... get the item and display it 1 by 1..... please provide  exmple...
0
Comment
Question by:Jacqueline_toh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 9

Accepted Solution

by:
mmuruganandam earned 25 total points
ID: 10702615
import java.text.DecimalFormat;
import java.util.Iterator;
import java.util.LinkedList;

public class Test
{
      public static void main(String[] args)
      {
            LinkedList list = new LinkedList();
            list.add("hello 1");
            list.add("hello 2");
            list.add("hello 3");
            list.add("hello 4");
            
            for (int i = 0; i < list.size(); i++)
            {
                  System.out.println((String)list.get(i));
            }
            
            Iterator iter = list.iterator();
            while (iter.hasNext())
            {
                  System.out.println((String)iter.next());
            }
      }
}


You can add this way.
I have provided two types of printing.


Regards,
Muruga
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10702654
Muruga, that goes slightly against the policies for homework. Anyway, there are some examples here as well:

http://www.javaalmanac.com/egs/java.util/coll_Lists.html
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10702677
mayankeagle,  you are some what right.  But his words doesn't seems like that.  So I have provided.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10702698
That is the problem with such short-worded questions. Anyway ;-) !
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 10702782
Tip: the middle part of the question reveals it: teacher's words!

;JOOP!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ejb on wildfly 5 45
SequenceInputStream example 3 21
dao vs facade design patterns 2 31
activeMQ Queue Messages Enqueued and Messages Dequeued 1 30
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question