Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


badrul hisham
cannot find symbol class array queue--plzz somebody help..
1 Answer(s)      2 years and 6 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();

} } }


Advertisement
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
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
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 - 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
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
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 tag library descriptor
Cannot find tag library descriptor  Cannot find tag library descriptor...? How to resolve in struts in eclipse
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
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 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
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
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
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 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
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
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
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
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 : 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 out last character of array
Find out last character of array  How we can find out the last character of array in java program
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
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
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
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
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
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
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
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
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
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
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
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
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
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 &
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
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
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
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
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
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 { public static void main(String
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
How to eliminate error," Could not find the main class: filecopy.FileCopy. Program will exit." ?
How to eliminate error," Could not find the main class: filecopy.FileCopy....) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: filecopy.FileCopy. Program will exit. Exception in thread "main" Java
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
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
Advertisements
 

 

 

DMCA.com