Education Menu

 

Features Menu

 

Additional Menu

 

Now Online

We have 37 guests online
 

@edulanka

 

Follow US

Twitter You Tube Google Plus
Pinterest Facebook EduLanka Blog

 

Information Zone

eduLanka Sinhala

Welcome to eduLanka.LK, Largest online education web site in Sri Lanka & most popular educational web site among Sri Lankan students. EduLanka, Best nonprofit & educational website is provided large numbers of online lessons, education related course information, teachers information, E books, examination result alerts, goverment job alerts, tuition class information, career guide for school leavers and more resources related to education in Sri Lanka. Edulanka provides education related resources from primary education, O-Level & A-Level education, University & Postgraduate education and vocational training education.

EduLanka IDN Domains http://එඩියුලංකා.ලංකා http://எடியுலங்கா.இலங்கை


jobs Mathematics SLAS Exam Dharma Education Results



 

Inside Online School

Share Us

Home Page Information Technology Java Programing (ජාවා වැඩසටහන්කරණය)

List Based Java Queue - Application + Example
Sunday, 03 April 2011 23:55

List Based Java Queue Application

Java Example and sample program for Data structure and algorithms. This application is based for Java Queue Data structure based on linked list. linked list java queue normal and simple sample application  can be download here with for all aditional pakages and additional files.

/*eduLanka Online education web site of Sri Lanka
-------- w w w . e d u L a n k a . l k ------------
java programs for University students - who follow courses - BIT - SLIIT and more
find more lessons in http://www.edulanka.lk This e-mail address is being protected from spambots. You need JavaScript enabled to view it
this programs under GNU licence
*/


import java.io.*;
import TerminalIO.*;

class QueueLt{
ListNode front;
ListNode rear;
ListNode newnode;

public QueueLt(){
front=rear=null;
}



public boolean isEmpty(){
return front==null;
}


public void enQueue(Object x){
newnode=new ListNode(x);
if(isEmpty())
front=rear=newnode;
else{
rear.next=newnode;
rear=newnode;
}
}



public Object deQueue(){
Object ele="Error";
if(isEmpty())
System.out.println("Queue is Empty");
else{
ele=front.element;
front=front.next;
}
return ele;
}




public void displayList(){
ListNode current=front;
if(isEmpty())
System.out.println("Queue is Empty");
else
while(current!=null){
System.out.println(current.element+" ");
current=current.next;
}
}
}


public class QueueList{
public static void main(String []arg){

int num;
String S=" ";
QueueLt myque=new QueueLt();
KeyboardReader input=new KeyboardReader();

S=input.readLine("Enter Your Text : ");
for(int i=0;i<S.length();i++)
myque.enQueue(S.charAt(i));

System.out.println("\nAfter Inserting\n");
myque.displayList();

System.out.println("\n\n\nDeleted Element is "+myque.deQueue()+" and After Deleting\n");
myque.displayList();

}
}


 

 

Add comment

Add comments relevant to this Article. මෙම ලිපියට අදාලව පමණක් අදහස් එකතු කරන්න.


Security code
Refresh

1.jpg

Download Toolbar

 
 

Most Popular Articles

Latest Articles

Copyright © 2005 - 2016 (ඉස්කෝලේ) eduLanka Online Education School of Sri Lanka