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
Solved

linked list

Posted on 2004-03-29
7
160 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
  • 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The viewer will learn how to implement Singleton Design Pattern in Java.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

856 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