You are here:   HomeJava ProgrammingJava ArrayLargest Number in an Array Java Example
by Dinesh Thakur Category: array

 

import java.util.*;

import java.io.*;
class linklst
{
        LinkedList linkedlist1=new LinkedList();
        String h;
        int i,n;
        Console console=System.console();
         public void createlinkedlist()
             {
                 h=console.readLine("\nHow many numbers you want to insert in linked list");
                 n=Integer.parseInt(h);
                 System.out.println("Enter numericals in linked list");
                 for(i=1;i<=n;i++)
                      {
                            h=console.readLine();
                            linkedlist1.add(h);
                      }
   
             }                                                                    
                public void viewlinkedlist()
                   {
                       System.out.println("Elements in linked list are");
                       System.out.println(linkedlist1);
                   }
        public void deletelinkedlist()
        {
             h=console.readLine("Enter the element to be removed from linked list");
             n=Integer.parseInt(h);
             linkedlist1.remove(h);
             System.out.println("Element is deleted from linked list");
        }
             public void insertlinkedlist()
              {
                  h=console.readLine("Enter the element to insert in linked list");
                  n=Integer.parseInt(h);
                  linkedlist1.addLast(h);
                  System.out.println("Element is inserted at the end in the linked list");
              }
                   public void updatelinkedlist()
                   {
                        h=console.readLine("Enter the element to update in linked list");
                        int loc=linkedlist1.indexOf(h);
                        h=console.readLine("enter the new element");
                        linkedlist1.set(loc,h);
                        System.out.println("Element is updated in the linked list");
                    }
}
class LinkedListJavaExample
 {
       public static void main(String args[])
       {
              Console console=System.console();
              int k;
              String h;
              linklst lst=new linklst();
              k=0;
              while(k!=6)
              {
                    System.out.println("\n\n1....Create a Linked List");           
                    System.out.println("2...View linked List");
                    System.out.println("3....Inserting in Linked list");                    
                    System.out.println("4....Deleting from Linked List");            
                    System.out.println("5..Updating element in linked List");              
                    System.out.println("6...Quit");
                    h=console.readLine(" enter ur choice 1/2/3/4/5/6 ");
                    k=Integer.parseInt(h);
                     switch(k)
                       {
                          case 1: lst.createlinkedlist();
                          break;
                          case 2: lst.viewlinkedlist();
                          break;
                          case 3: lst.insertlinkedlist();
                          break;
                          case 4: lst.deletelinkedlist();
                          break;                                                  
                          case 5: lst.updatelinkedlist();
                          break;                                                                        
                      }
             }
      }
}

Linked List in Java Example





Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular





Popular Article