linked list

linked list

how to write a program using a linked list, that will prompt a user to enter 10 names and display them in reverse

View Answers

September 14, 2011 at 4:20 PM

import java.util.*;
class  LinkedListExample
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.println("Add elements to LinkedList: ");
        LinkedList<String> list=new LinkedList<String>();
        for(int i=1;i<=10;i++){
            String name=input.nextLine();
            list.add(name);
        }
        Collections.reverse(list);

        System.out.println("List of names in reverse order:");

        for (String names : list) {
            System.out.println(names);
        }
    }
}

September 15, 2011 at 9:19 PM

the code does not run....

LinkedList does not take papameters

Ads









Related Tutorials/Questions & Answers:
linked list
linked list  program for single linked list
Linked list
Linked list  what is difference btw linked list in datastructure and linked list in java
Advertisements
linked list
linked list  hi i have basal problem what is the linked list
linked list
linked list  Hi i have a problem with linked list ! how and where i can use linked list? please give me some example.   Please visit...://www.roseindia.net/java/beginners/linked-list-demo.shtml
linked list
linked list   how to add student and mark and number from file in linked list and print them also how to make search function plz can help me sooon
Linked List
in the following logical linked list represents Computer Number. 76(head) 98 54...? to ?66?. The segment should also display the new contents of the linked list. ii. Write a program segment to copy all ?Dell? computers to a new linked list
linked list
linked list   how to write a program using a linked list...); System.out.println("Add elements to LinkedList: "); LinkedList<String> list=new...); } Collections.reverse(list); System.out.println("List of names in reverse order
linked list
program to manage the registration details for the institute. 1. Use a linked list to manage the details of all registered students. a. Create your own linked list...linked list  Data Structures An English institute has a different
stack using linked list
stack using linked list  how to implement stack using linked list
HELP Generic linked list
HELP Generic linked list  How to create Generic linked list example program in Java
Linked list implementation
Linked list implementation  How to create linkedlist by using array in java? and also How to manipulate
java linked list urgent!!!
java linked list urgent!!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
Core java linked list example
Core java linked list example  What is the real time example for linked list
about linked list
about linked list   hey can u help me soon ?? i want to add student... in linked list   import java.util.*; class StudentData{ int id...; LinkedList<StudentData> list=new LinkedList<StudentData>(); Scanner
ModuleNotFoundError: No module named 'linked_list'
ModuleNotFoundError: No module named 'linked_list'  Hi, My Python... 'linked_list' How to remove the ModuleNotFoundError: No module named 'linked_list' error? Thanks   Hi, In your python environment
Issue with tutorial realted to insertion in middle in Linked List
Issue with tutorial realted to insertion in middle in Linked List  insert in middle in Linked list will take O(N) instead as displayed as O(1
Write a MoveFirst() for Circular Linked List
Write a MoveFirst() for Circular Linked List  write a MoveFirst(T elt) method to point the head at that element. Then the tail would point to the element before that one. so if i have " one two three four) and the moveFirst(two
ModuleNotFoundError: No module named 'another-linked-list'
ModuleNotFoundError: No module named 'another-linked-list'  Hi, My... named 'another-linked-list' How to remove the ModuleNotFoundError: No module named 'another-linked-list' error? Thanks   Hi
ModuleNotFoundError: No module named 'doubly_linked_list'
ModuleNotFoundError: No module named 'doubly_linked_list'  Hi, My... named 'doubly_linked_list' How to remove the ModuleNotFoundError: No module named 'doubly_linked_list' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'doubly_linked_list'
ModuleNotFoundError: No module named 'doubly_linked_list'  Hi, My... named 'doubly_linked_list' How to remove the ModuleNotFoundError: No module named 'doubly_linked_list' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'linked_list_mod'
ModuleNotFoundError: No module named 'linked_list_mod'  Hi, My... named 'linked_list_mod' How to remove the ModuleNotFoundError: No module named 'linked_list_mod' error? Thanks   Hi, In your python
delete a node from singly linked list in java
delete a node from singly linked list in java  Write a program(in java), if given a pointer to a node (not the tail node) in a singly linked list, delete that node from the linked list.   could you tell your question
Multiplication of two polynomials using linked list in java
Multiplication of two polynomials using linked list in java  I am doing a program "Multiplication of two polynomials using linked list in java... for polynomial linked list import java.util.Scanner; class Node { public int
write a java pogram to add elements to linked list using keyboard and display it
write a java pogram to add elements to linked list using keyboard and display it  write a java pogram to add elements to linked list using keyboard and display
How to create a Student data base using Linked List in java
How to create a Student data base using Linked List in java  I want a program by using linked list in java. The data stored must... Record2 sandhya 22 5apr By using linked list I hve
How would I get this linked list in alphabetical order?
How would I get this linked list in alphabetical order?   import java.io.*; import java.util.Scanner; public class LinkedList2 { public... name = "List nodes:\n"; LinkedListNode current = head; while(current

Ads