Java 使用列表创建队列时发生编译错误

Java 使用列表创建队列时发生编译错误,java,compilation,queue,Java,Compilation,Queue,我的项目要求我使用列表创建一个FIFO队列,并且我必须创建简单的方法来放置、移除和返回对象等。但是当我编译以下代码时: import java.io.PrintStream; import java.util.NoSuchElementException; class IntQueueImpl { public int size; private Node head, tail; private class Node { int item; Node next;

我的项目要求我使用列表创建一个FIFO队列,并且我必须创建简单的方法来放置、移除和返回对象等。但是当我编译以下代码时:

import java.io.PrintStream;
import java.util.NoSuchElementException;

class IntQueueImpl  { 

public int size;
private Node head, tail; 
private class Node { 
    int item; 
    Node next; 
    Node(int item) { 
        this.item = item; 
        next = null; }
        } 

IntQueueImpl(int max) { 
    head = null; tail = null; 
    }


public boolean isEmpty() { 
    return (head == null); 
    }

    public void put(int item) { 
    Node t = tail; 
    tail = new Node(item); 
    if (isEmpty()) head = tail; 
    else t.next = tail;
    size++;
    } 


public int get() throws NoSuchElementException;{ 
    if ( isEmpty() ) 
    throw new NoSuchElementException();
    int v = head.item; 
    Node t = head.next; 
    head = t; 
    return v;

    } 

    public int peek() throws NoSuchElementException{
    if ( isEmpty() ){ 
    throw new NoSuchElementException();
    }
    int peekelement =head.item;
    return peekelement;
    } 


    public int size(){

    if(isEmpty()) return 0;

    else return size;

    }

}
它给了我以下错误:

 IntQueueImpl.java:35: error: missing method body, or declare abstract
    public int get() throws NoSuchElementException;{
               ^
 IntQueueImpl.java:41: error: return outside method
            return v;
我必须知道这意味着什么或如何修复它….

在第34行,您有:

public int get() throws NoSuchElementException;{
删除该分号,然后查看是否修复了编译器错误:

public int get() throws NoSuchElementException {

删除“;”怎么样?在public中,int get()抛出NoSuchElementException;{“

在{code>public int get()抛出NoSuchElementException;{中,在{brace]之前有一个分号。删除该分号。