Ask your own question, for FREE!
Computer Science 24 Online
OpenStudy (ajprincess):

Can someone please help me?

OpenStudy (ajprincess):

When I try to run java program in jdk1.7.0_07 I get an error message saying Main method not found in class Queue, please define the main method as public static void main(String[] args) I have defined t that way. I am unable to find the cause for this problem. Besides the same program runs perfectly in netbeans

OpenStudy (anonymous):

Could you post Queue.java here?

OpenStudy (ajprincess):

Sure. It is actually Queue3.java import java.io.*; class Queue3 { private int maxSize; private char[] queueArr; private int front; private int rear; private int nItems; public Queue3(int s) { maxSize=s; queueArr=new char[maxSize]; front=0; rear=-1; nItems=0; } public void insert(char letter) { if(rear==maxSize-1) rear=-1; queueArr[++rear]=letter; nItems++; } public char remove() { char temp=queueArr[front++]; if(front==maxSize) front=0; nItems--; return temp; } public char peekFront() { return queueArr[front]; } public boolean isEmpty() { return (nItems==0); } public boolean isFull() { return (nItems==maxSize); } public int size() { return nItems; } } class QueueApp3 { public static void main(String[] args) throws IOException { BufferedReader keyboard = new BufferedReader (new InputStreamReader(System.in)); int a; int b; String c; int d; System.out.print("Enter the size of the array:"); a=Integer.parseInt(keyboard.readLine()); Queue3 theQueue=new Queue3(a); System.out.print("Enter the number of items to be inserted:"); b=Integer.parseInt(keyboard.readLine()); for(int i=1;i<=b;i++) { System.out.print("Enter the item:"); c=keyboard.readLine(); theQueue.insert(c.charAt(0)); } System.out.print("Enter the number of items to be removed:"); d=Integer.parseInt(keyboard.readLine()); for(int k=1;k<=d;k++) { theQueue.remove(); } System.out.print("Enter the number of items to be inserted:"); b=Integer.parseInt(keyboard.readLine()); for(int i=1;i<=b;i++) { System.out.print("Enter the item:"); c=keyboard.readLine(); theQueue.insert(c.charAt(0)); } while(!theQueue.isEmpty()) { char n=theQueue.remove(); System.out.print(n); System.out.print(" "); } System.out.println(" "); } }

OpenStudy (ajprincess):

It works nw. Thanx a lot for tryng to help me @slotema

OpenStudy (anonymous):

And another job well done... Wait... I didn't do much ;) What was the problem?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!