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

Ads
 

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;
    }

}

Ads









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
the java error cannot find symbol. In this example a class name 'cannot find... “cannot find symbol”. The reason behind cannot find symbol error.../src/ Cannotfindsymbol.java:11: cannot find symbol symbol: variable z
Advertisements
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 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 : public class CannotFindSymbol...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
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
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  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
Help With an Array
Help With an Array  // ******************** // Sales.java // // Reads.... // // ******************** import java.util.Scanner; public class Sales { public static void main(String... need help from this part on. I need that part corrected and add a portion
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
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
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
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.
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
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
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
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
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
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
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
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
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
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
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
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 &

Ads