Solved

linked list

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
get weblogic logged in user in java 2 57
Java Jpanels and Jframe 8 28
what is a "java.lang.System Property"   ? 20 57
Cipher Configuration on Apache HTTPD 4 50
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 video teaches viewers about errors in exception handling.
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…

919 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

19 Experts available now in Live!

Get 1:1 Help Now