Solved

linked list

Posted on 2004-03-29
7
156 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:mayankeagle
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:mayankeagle
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now