Select The Lesson:
Welcome to Online Education Of Sri Lanka
/*eduLanka Online education web site of Sri Lanka -------- w w w . e d u L a n k a . c o m ------------ java programs for University students - who follow courses - BIT - SLIIT and more find more lessons in http://www.it.edulanka.com eduLanka@gmail.com this programs under GNU licence */ import TerminalIO.*; import java.io.*; class ListNode{ Object element; ListNode next; public ListNode(Object ele){ this(ele,null); } public ListNode(Object ele,ListNode n){ element=ele; next=n; } } class StackLt{ ListNode top; ListNode newnode; public StackLt(){ top=null; } public boolean isEmpty(){ return top==null; } public void push(Object x){ newnode = new ListNode(x,top); top=newnode; } public Object pop(){ Object ele="Error"; if(isEmpty()){ System.out.println("Stack Error");} else{ ele=top.element; top=top.next; } return ele; } public void displayList(){ ListNode current=top; if(isEmpty()) System.out.println("List Empty"); else{ while(current!=null){ System.out.println(current.element+" "); current=current.next; } } } } public class StackList{ public static void main(String arg[]){ int num; /* String S=" "; System.out.println("Enter Your Text"); S=input.readLine(); for(int i=0;i