Solved

linked list

Posted on 2004-03-29
7
158 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

770 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