Home Answers Viewqa Java-Beginners cannot find symbol class array queue--plzz somebody help..

 
 


badrul hisham
cannot find symbol class array queue--plzz somebody help..
1 Answer(s)      a year and 7 months ago
Posted in : Java Beginners

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 Pages:
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
Java error cannot find symbol
a class name 'cannot find symbol'. Inside the main method we have initialized... Java error cannot find symbol       The java error cannot find symbol occurred when a Compiler
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
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???  
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
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
Currency Symbol problem
Currency Symbol problem  Hi All, My Server side code... to show this like RM 12345. How to solve this? Any help or idea is greatly..., The java.util.Locale class defines the available local: Locale.CANADA Locale.CANADA_FRENCH
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
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
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
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
Cannot find tag library descriptor
Cannot find tag library descriptor  Cannot find tag library descriptor...? How to resolve in struts in eclipse
combobox cannot be resolved in JavaFX
combobox cannot be resolved in JavaFX  I want to design one... javafx.stage.Stage; public class V_hgj extends Application{ public static void...; public class C_hgj implements Initializable{ @FXML private ComboBox fruitCombo
cannot do the additional operator
cannot do the additional operator  i got problem with additional and multiplication operator...please anyone help me <html> <head>... align="center" class="style1">Simple Calculator</p> <!-- HTML form
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
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
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
array
is an example that store some integers into an array and find the occurrence of each number from the array. import java.util.*; public class SearchNumberOccurrence...array  Hi i have array like {1,2,3,4,,5,5,6,6} then how can i
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
Netbeans Array help
of rolls possible within the array Help plese!   Hi Friend, Try...Netbeans Array help  Ok here is my code- * * To change this template... java.util.Random; /** * */ public class ContinueRollDie { * @param args
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
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
cannot open .jar files by double click
the error as " main class cannot be found " plz help i'm stucked now still i have...cannot open .jar files by double click  I'm having a problem i create a .jar file in net beans and yesterday it work right b y and double click but i
Array List
Array List  Could somebody help me to solve this question. I am glad to hear ideas or answers from everyone. The situation: Complete the class House and HouseApp below to display class House{ int lotNo; String type
JavaScript Array
reverse example JavaScript Array class have one method reverse....   JavaScript array slice JavaScript array class's slice... by using the sort() method of Array class in JavaScript.  
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
Java 2 micro editionJ
symbol class TextField cannot find symbol variable TextField please help me out... cannot find symbol class Form cannot find symbol class Display cannot find symbol class TextField cannot find symbol class Ticker cannot find symbol class
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 &
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
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 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
about inner class
(); } } in this i got compile time error as: cannot find symbol method m2...about inner class  class Outer { class Inner{ public void m1(){ System.out.println("Inner class Method"); } } public void m2(){ Inner i = new Inner
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
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
java loan calculator applet help
); that java cannot find symbol and it points to where Loan is after new...java loan calculator applet help  Hi, I could use some help... javax.swing.border.TitledBorder; public class LoanCalculator extends JApplet implements
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
Java error cannot read
made Symbol. This error occurred because the programmer write the wrong class... Java error cannot read       The Java error cannot read occurred when a programmer do
ARRAY - Java Beginners
ARRAY  How To Find Out Unique Elements Of Given Array... Plz Help Me?  Hi Friend, Try the following code: import java.util.*; public class ArrayElements { public static void main(String[] args
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 : 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 sum of the squares of Array elements
Find sum of the squares of Array elements In this section, you will learn how to compute the sum of the squares of the array elements. For this, we have allowed the user to enter 5 numbers, to be stored into the array. Then we have
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
how to find subarray from given large 2d array of arbritary dimension
how to find subarray from given large 2d array of arbritary dimension ... java.util.Scanner; public class SubMatrix { public static void main(String... to print the subarray of any dimension from given array file. i have tried upto
array example - Java Beginners
array example  hi!!!!! can you help me with this question pleaseeeeeeeeeeeeeeee... 1. Create a new class (in the employees package) called Dependent... dependents to Employee that is an array of Dependent objects, and instantiate a five
need help with two dimensional array that takes input from user and bubble sorts and selections sorts
need help with two dimensional array that takes input from user and bubble... cannot figure out how i can declare a two dimensional array without knowing how... that performs Bubble Sort using 2 d array. public class BubbleSortWith2D
SubString help - Java Beginners
SubString help  Hi , I would appreciate if somebody could help me...... substring . If it find 35 zeros i need 10 digits in front of it along with those... class FileReadExample { public static void main(String args[]) throws IOException
how to find largest number? - Java Interview Questions
); } } i don't know how to add code to find the largest number.. please help...how to find largest number?  this is my java coding: import java.util.Scanner; import java.io.*; public class readNumbers { public static
equal symbol expected in jsp - JSP-Servlet
equal symbol expected in jsp   Hi frndz i am using following code... error org.apache.jasper.JasperException: /upload_page.jsp(2,26) equal symbol...) org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:166) Can anyone help me

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.