cannot find symbol class array queue--plzz somebody help..

cannot find symbol class array queue--plzz somebody help..

import java.util.*;

public class Test {

public static void main(String[] args) { ArrayQueue<String> q = new ArrayQueue<String>(6);

System.out.println("A new queue is an empty queue ... " + q.isEmpty());
System.out.println("Adding six strings to the queue ...");
System.out.println("A: " + q.join(new String("A")));
System.out.println("B: " + q.join(new String("B")));
System.out.println("C: " + q.join(new String("C")));
System.out.println("D: " + q.join(new String("D")));

System.out.println("A: " + q.leave(new String("A")));
System.out.println("B: " + q.leave(new String("B")));
System.out.println("C: " + q.leave(new String("C")));

System.out.println("E: " + q.join(new String("E")));
System.out.println("F: " + q.join(new String("F")));
System.out.println("G: " + q.join(new String("G")));
System.out.println("H: " + q.join(new String("H")));
System.out.println("I: " + q.join(new String("I")));

System.out.println("G: " + q.leave(new String("G")));
System.out.println("H: " + q.leave(new String("H")));
System.out.println("I: " + q.leave(new String("I")));

System.out.println("The queue is now full ..." + q.isFull());
System.out.println("Adding a string to a full queue ...");
System.out.println("tagore: " + q.join(new String("tagore")));
System.out.println("Emptying the queue item by item ...");

while (!q.isEmpty()) {
System.out.println(q.retrieve());
q.leave();

} } }

View Answers

October 10, 2011 at 11:56 AM

The package java.util.* does not contain the class ArrayQueue. It is found in another package. Either you import that package through the jar file or implement the class ArrayQueue.

ArrayQueue.java:

class ArrayQueue implements Queue 
{

    static final int defaultsize = 100;

    Object data[];
    int head;
    int tail;
    int size;

    ArrayQueue(int maxsize) 
    {
        data = new Object[maxsize];
        head = 0;
        tail = 0;
        size = maxsize;
    }

    ArrayQueue() 
    {
        data = new Object[defaultsize];
        head = 0;
        tail = 0;
        size = defaultsize;
    }

    public void enqueue(Object elem) 
    {
    Assert.notFalse((tail+1)%size != head, "Queue Full");
    data[tail] = elem;
    tail = (tail + 1) % size;
    }

    public Object dequeue() 
    {
    Object retval;

    if (head == tail)
        return null;
    retval = data[head];
    head = (head + 1) % size;
    return retval;
    }

    public boolean empty() 
    {
    return head == tail;
    }

    public String toString()
    {
    String result = "[";
        int tmpHead = head;
    if (tmpHead != tail)
    {
            result = result + data[tmpHead];
            tmpHead = (tmpHead + 1) % size;
            while (tmpHead != tail)
            {
        result = result + "," + data[tmpHead];
                tmpHead = (tmpHead + 1) % size;
        }
    }
    result = result + "]";
    return result;
    }

}









Related Tutorials/Questions & Answers:
cannot find symbol class array queue--plzz somebody help..
cannot find symbol class array queue--plzz somebody help..  import java.util.*; public class Test { public static void main(String[] args.... ArrayQueue.java: class ArrayQueue implements Queue { static final int defaultsize
Java error cannot find symbol
didn’t Imported the class name. Following example will help you understand the java error cannot find symbol. In this example a class name 'cannot find... “cannot find symbol”. The reason behind cannot find symbol error
Advertisements
Java error cannot find symbol
error cannot made symbol. For this we have a class name 'cannot find symbol... Java error cannot find symbol       The java error cannot find symbol
cannot find symbol method nextchar()??
cannot find symbol method nextchar()??  import java.util.Scanner; public class Calc5{ public static void main(String args[]){ Scanner... } // end of class
cannot find symbol - Java Beginners
cannot find symbol  public class Areatest { public static void main(String[]args) { Figure[]figures={new Triangle(2.0,3.0,3.0),new Rectangle(4.0,6.0),new Square(5.0)}; for(int i=0;i
cannot find symbol method append(String)
cannot find symbol method append(String)  what is the solution for cannot find symbol method append(String)?   Hi, Check tutorials: How To Append String In Java? Java - StringBuffer class in Java Thanks
cannot find symbol method append(String)
cannot find symbol method append(String)  what is the solution for cannot find symbol method append(String)?   Hi, Check tutorials: How To Append String In Java? Java - StringBuffer class in Java Thanks
Java error cannot find symbol
illustrates what is cannot find symbol :ADS_TO_REPLACE_1 public class...Java error cannot find symbol In this section you will learn about "cannot find symbol" in java. Java cannot find symbol is a type of error occurs
JSP cannot find symbol error - JSP-Servlet
JSP cannot find symbol error  Suppose-- we created 'a.jsp' in which we make a database connection... how to retrieve 'new' here... If I want to access the 'new' string within the form what should i do???  
cannot find symbol Scanner sc = new Scanner(system.in)
cannot find symbol Scanner sc = new Scanner(system.in)  In my one of the program in getting the error: cannot find symbol Scanner sc = new Scanner(system.in) How to resolve the error: cannot find symbol Scanner sc = new Scanner
Cannot find tag library descriptor
Cannot find tag library descriptor  Cannot find tag library descriptor...? How to resolve in struts in eclipse
HELP WITH ARRAY
HELP WITH ARRAY  Hi i would like this program: public class ArrayApp... ([]) it should find the number and print it "Found (number)" pls. help me...) System.out.println("Can't find" + searchId); else System.out.print("Found
System.out.println cannot be written inside a class
System.out.println cannot be written inside a class  why System.out.println cannot be written inside a class
Help With an Array
Help With an Array  So what Im trying to do is write an array declaration to represent students names for a class and homework grades for each student. I have included my arrays for a declaration for 25 students names in a class
please please i wanna insertion sort program find calendar to array value (1000,5000,10000), please help me
Insertion sort program find calendar to array value 1000,5000,10000  program find calendar for insertion sort in jfram to array 1000
Help With an Array
Help With an Array  // ******************** // Sales.java // // Reads.... // // ******************** import java.util.Scanner; public class SalesADS_TO_REPLACE_1 { public static...] < ) is wrong but I need help from this part on. I need that part corrected
error cannot access class com.opensymphony.xwork2.ActionContext, wrong version
error cannot access class com.opensymphony.xwork2.ActionContext, wrong version  Error(1,32): cannot access class com.opensymphony.xwork2.ActionContext; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0
Help
\SlideImageMIDlet.java:36: cannot find symbol symbol : class SlideMenu location...\2.5.2\apps\SlideImageMIDlet\src\SlideImageMIDlet.java:20: cannot find symbol symbol : class SlideMenu location: class IconsCanvas SlideMenu menu = null; ^ C
Error: Cannot find module 'jasmine-core'
Error: Cannot find module 'jasmine-core'  Hi, I am trying to make...: karma start Its throwing following error: Error: Cannot find module 'jasmine...; ^ Error: Cannot find module 'jasmine-core' at Function.Module.
array find all possible dimension
array find all possible dimension  Given array: int[] dimension = { 1, 2, 3 }; That produces the output: 1 2 3 12 13 23 123 I'm new to array...i... if someone could help...thanks
Netbeans Array help
Netbeans Array help  Ok here is my code- * * To change this template... java.util.Random; /** * */ public class ContinueRollDie { * @param args... array to tally the actual combinations of rolls. A roll of 2 and 7 would
Find position of an array element
Find position of an array element In this section, you will learn how to find the index of an array element. For this, we have allowed the user to enter the array elements of their choice and also the number whose index value
Find out last character of array
Find out last character of array  How we can find out the last character of array in java program
cannot find java.exe error while opening netbean5.5 - IDE Questions
cannot find java.exe error while opening netbean5.5  HI, 1)i am working netbean5.5 tool.I got the error of cannot find c:\programfiles\java... solve this error , plz help me Regards Gokul
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
Cannot find FacesContext exception - Java Server Faces Questions
Cannot find FacesContext exception  Hi all, I am into an web application,where we are using Richfaces. Now, When I try to create a new Jsp page using taglibs[faces, html], getting 'Cannot find FacesContext' exception. What
Difference between abstract class and an interface
now a days in core java. This section will help you to find the differences... will find the difference as follows : First difference, an abstract class... an abstract class is class which cannot extends multiple classes because java
javax.servlet.jsp.JspException: Cannot find FacesContext - Java Server Faces Questions
javax.servlet.jsp.JspException: Cannot find FacesContext  exception javax.servlet.ServletException: Cannot find FacesContext...(HttpServlet.java:802) root cause javax.servlet.jsp.JspException: Cannot find
Find a missing element from array
Find a missing element from array We have two arrays A and B where B consists... the array B. From these two arrays, we have to find the missing element from the second array i.e from B. For this, we have calculated the sum of elements from both
Error : javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
Error : javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope  I am getting following error in my struts... javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN
JavaScript Array Class
JavaScript Array Class       In this section, you will study how to use Array class in JavaScript.  The Array class is one of the predefined classes available in JavaScript
To find first two maximum numbers in an array
To find first two maximum numbers in an array  Java program to find first two maximum numbers in an array,using single loop without sorting array
Find Second Largest Number from an Array
Find Second Largest Number from an Array This section illustrates you how to find the second largest number from an array. For this purpose, we have allowed the user to enter the array elements of their choice and determine the largest
USE ARRAY TO FIND THE LARGEST NUMBER AND OCCURRENCE
USE ARRAY TO FIND THE LARGEST NUMBER AND OCCURRENCE  i have some exercise from my lecturer and I still can't understand about ARRAY. here it is: write a program that reads 10 numbers from the keyboard. find the largest number
could not find a getter for id in contact class
could not find a getter for id in contact class   could not find a getter for id in contact class
how to find inverse of n*n 2d array in java
how to find inverse of n*n 2d array in java  I reached upto code... is: public class ReadContents{ public static void main(String args...(); } Please help me to solve
Cannot convert 1/23/13 1:18 PM of type class java.util.Date to class java.sql.Timestamp
Cannot convert 1/23/13 1:18 PM of type class java.util.Date to class java.sql.Timestamp  I keep receiving this error every time i select date through jsf calendar, I declared my variable as Timestamp not date. my db is postgresQl
Need help in constructing a 2 dimensionla array?
Need help in constructing a 2 dimensionla array?  Construct a 2 dimensional array that for each entry in the array, display the index of the first... array. import java.util.*; public class twoDimension{ public static void main
plz Help me find the correct programs answers
plz Help me find the correct programs answers   Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff... Create a calculator class which will have methods add, multiply, divide &
Unable to find Software Updates in Help menu in MyEclipse
Unable to find Software Updates in Help menu in MyEclipse  Hi, I am... Software Updates under Help menu, so I couldnt install the corresponding plugins to my eclipse. Can anyone please help me. Thanks, Suriya   Hi Suriya
Please help need quick!!! Thanks
(); ^ TestRenforthBoatRace.java:38: cannot find symbol symbol : variable blueboat location: class...(); ^ TestRenforthBoatRace.java:35: cannot find symbol symbol : variable redboat location...(); ^ TestRenforthBoatRace.java:36: cannot find symbol symbol : variable
Find Month name using DateFormatSymbols class.
Find Month name using DateFormatSymbols class. In this tutorial, you will learn how to find the month name using DateFormatSymbols class. The class... DateFormat and SimpleDateFormar use DateFormatSymbols class to encapsulate
could not find the main class programm will exit - error
could not find the main class programm will exit - error  when i tried to run the below mentioned programmed it gives a error states - could not find main class programm will exit. class Car { String name: String Color
Create a int array with the help of int buffer.
Create a int array with the help of int buffer.  In this tutorial, we will see how to create a int array with the help of int buffer. IntBuffer API: The java.nio.lntBuffer class extends java.nio.Buffer class. It provides
How to create a long array with the help of long buffer.
How to create a long array with the help of long buffer.  In this tutorial, we will see how to create a long array with the help of long buffer. LongBuffer API: The java.nio.LongBuffer class extends java.nio.Buffer class
please help me to solve this question about array
please help me to solve this question about array  write a program thatt stores vowels (a,e,i,o and u)in an array. Ask the user to enter any... java.util.Scanner; public class Example1 {ADS_TO_REPLACE_1 public static void
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
Find Array element from index using GUI
Find Array element from index using GUI In this tutorial, you will learn how to create an GUI application to find an array element from its index. For this, we have created an an array of 100 randomly chosen integers and allow
Create a short array with the help of short buffer.
Create a short array with the help of short buffer.  In this tutorial, we will see how to create a short array with the help of short buffer. ShortBuffer API: The java.nio.ShortBuffer class extends java.nio.Buffer class

Ads