Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

ajprincess

  • 3 years ago

Can someone please help me?

  • This Question is Closed
  1. ajprincess
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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

  2. slotema
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Could you post Queue.java here?

  3. ajprincess
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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(" "); } }

  4. ajprincess
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  5. slotema
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy