John Delmark Aguilar
Would you like to react to this message? Create an account in a few clicks or log in to continue.
John Delmark Aguilar

Personal Forum
 
HomeSearchLatest imagesRegisterLog in

 

 Linked List Java Program

Go down 
AuthorMessage
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

Linked List Java Program Empty
PostSubject: Linked List Java Program   Linked List Java Program Icon_minitimeTue Oct 23, 2012 5:28 pm



LinkedList Syntax:
Back to top Go down
https://delmark.forumtl.com
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

Linked List Java Program Empty
PostSubject: Re: Linked List Java Program   Linked List Java Program Icon_minitimeTue Oct 23, 2012 8:10 pm

Code:

import java.util.*;
class LLS{
  public static void main(String [] ecs){
    LinkedList LLL = new LinkedList();
    Scanner sc=new Scanner(System.in);
    System.out.println("LinkedList Elements " + LLL);
    System.out.println("Enter an Option\n1 - AddFirst\t2 - AddLast\t3 - Add @ specified index\t4 - RemoveFirst\n\t5 - RemoveLast\t6 - Remove @ specified index\t7 - exit");
   
    int ch = 0;
    int elem = 0;
    int ind = 0;
   
    do{
      System.out.print("Choice: ");
      ch = sc.nextInt();
      if(ch==1){
       
        System.out.print("Enter element to add\n");
        elem = sc.nextInt();
        LLL.addFirst(elem);
      }
      if(ch==2){
        System.out.print("Enter element to add\n");
        elem = sc.nextInt();
        LLL.addLast(elem);
      }
      if(ch==3){
        System.out.print("Enter index: ");
        ind = sc.nextInt();
        System.out.print("Enter element: ");
        elem = sc.nextInt();
        LLL.add(ind,elem);
      }
      if(ch==4){
        LLL.removeFirst(); 
      };
      if(ch==5){
        LLL.removeLast();
      }
      if(ch==6){
        System.out.print("Enter index: ");
        ind = sc.nextInt();
        LLL.remove(ind);
      }
      System.out.println("LinkedList Elements " + LLL); 
     
    }while(ch!=7);
  }
}
Back to top Go down
https://delmark.forumtl.com
 
Linked List Java Program
Back to top 
Page 1 of 1
 Similar topics
-
» List Of Java Keywords
» Compiling Java Program
» Java Comments
» Payroll Java
» Java Programming Index

Permissions in this forum:You cannot reply to topics in this forum
John Delmark Aguilar :: dElmARk Productions :: Java Programs :: Tutorials-
Jump to: