write a java pogram to add elements to linked list using keyboard and display it

Ads
 

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

View Answers

January 28, 2011 at 4:21 PM

Hi Friend,

Try this:

import java.util.*;
class LinkedListExample
{
    public static void main(String[] args) 
    {
        LinkedList<String> list=new LinkedList<String>();
        Scanner input=new Scanner(System.in);
        System.out.print("how many elemenst do you want to add: ");
        int num=input.nextInt();
        for(int i=0;i<num;i++){
            System.out.print("Add Element: ");
            String element=input.next();
            list.add(element);
        }
        System.out.println();
        System.out.println("LinkedList elements are: ");
        for(int i=0;i<list.size();i++){
         System.out.println(list.get(i));
        }
    }
}

Thanks

Ads









Related Tutorials/Questions & Answers:
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
stack using linked list
stack using linked list  how to implement stack using linked list
Advertisements
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
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
Write a java program to display the season given the month using switch case
Write a java program to display the season given the month using switch case  Write a java program to display the season given the month using switch case
How to Display Duplicate elements from more than one List in java?
How to Display Duplicate elements from more than one List in java?  How to Display Duplicate elements from more than one List in java? //I mean common elements from two List? Ex: List a1=new ArrayList(); a1.add(50
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
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   import...); System.out.println("Add elements to LinkedList: "); LinkedList<String> list=new
java list program for common elements
java list program for common elements  hi I want program using java collections list which takes two array list elements and display common elements in both the list as an output   Please visit the following link
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
Linked List
? 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... in the following logical linked list represents Computer Number. 76(head) 98 54
write a program to remove the element from hashset using keyboard.
write a program to remove the element from hashset using keyboard.  write a program to remove the element from hashset using keyboard
Linked list
Linked list  what is difference btw linked list in datastructure and linked list in java
linked list
number of students register each semester. You are required to write a Java 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
java pogram
java pogram   i am requesting to admin please send me the code in which i can check the email address that is it in 4 octit and octit value lie between 0 to 255 my email
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
write a programm using java
write a programm using java  print the following using java programming
how to display duplicate elements with out using collection Frame work?
how to display duplicate elements with out using collection Frame work?  how to display duplicate elements with out using collection Frame work
linked list
://www.roseindia.net/java/beginners/linked-list-demo.shtml...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
linked list
linked list  program for single linked list
write a program to create an arraylist with string(add,remove) operation.and value should be enter through keyboard.
write a program to create an arraylist with string(add,remove) operation.and value should be enter through keyboard.  write a program to create an arraylist with string(add,remove) operation.and value should be enter through
write a program to create an arraylist with string(add,remove) operation.and value should be enter through keyboard.
write a program to create an arraylist with string(add,remove) operation.and value should be enter through keyboard.  write a program to create an arraylist with string(add,remove) operation.and value should be enter through
write a program to create an vector with string(add,remove) operation.and value should be enter through keyboard.
write a program to create an vector with string(add,remove) operation.and value should be enter through keyboard.  write a program to create an vector with string(add,remove) operation.and value should be enter through keyboard
Linked List Example In Java
list = new LinkedList(); // add elements to the linked list list.add("W...Linked List Example In Java LikedList implements List interface which..."); System.out.println("Original contents of list: " + list); // remove elements from the linked
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

Ads