import java.util.*; import java.io.*; class SimpleLl { public int data1; public String data2; public SimpleLl nextLink; public SimpleLl(int d1, String d2) { data1=d1; data2=d2; } public void printLink() { System.out.print("the data u entered is:"+data1+"&"+data2); } } class Link { private SimpleLl first; private SimpleLl current; //private SimpleLl previous; public Link() { first=null; current=null; //previous=null; } public boolean isEmpty() { return first==null; } public void insertObject(int ob1, String ob2) { SimpleLl link=new SimpleLl(ob1,ob2); if(isEmpty()) { first=link; current=link; //previous=link; } else { current.nextLink=link; current=current.nextLink; } } public SimpleLl Delete() { SimpleLl temp=first; first=first.nextLink; return temp; } public void printList() { SimpleLl currentLink = first; System.out.print("List: "); while(currentLink != null) { currentLink.printLink(); currentLink = currentLink.nextLink; } System.out.println(""); } } class LinkedTest { public static void main(String[] args) throws IOException { Link ll = new Link(); System.out.println("please press one(1) for enter object to the linkedlist:"); System.out.println("please press one(2) for desplaying object from the linkedlist:"); System.out.println("please press one(3) for delete object from the linkedlist:"); System.out.println("please press one(4) for sorting object from the linkedlisr:"); BufferedReader reader; reader = new BufferedReader(new InputStreamReader(System.in)); int value = Integer.parseInt(reader.readLine()); switch(value) { case 1: System.out.print("enter the object 1 :"); int value1 = Integer.parseInt(reader.readLine()); System.out.print("enter the object 2 :"); String value2= reader.readLine(); ll.insertObject(value1,value2); // ll.printList(); break; case 2: ll.printList(); break; case 3: ll.Delete(); break; default: } } }