我正在尝试一些代码,但我无法编译它。有什么错误吗?我附上了下面的代码。
import java.util.*;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
public class Node
{
private int nodeId;
private List<Connection> outboundConnections = new ArrayList<>();
public Node(int nodeId)
{
this.nodeId = nodeId;
}
public void addConnection(Connection connection)
{
this.outboundConnections.add(connection);
}
}
当我编译时,我得到了这种错误:
Node.java:9: error: cannot find symbol
private List<Connection> outboundConnections = new ArrayList<>();
^
symbol: class Connection
location: class Node
Node.java:16: error: cannot find symbol
public void addConnection(Connection connection)
^
symbol: class Connection
location: class Node
Node.java:9: error: unexpected type
private List<Connection> outboundConnections = new ArrayList<>();
^
required: class
found: <E>ArrayList<E>
where E is a type-variable:
E extends Object declared in class ArrayList
3 errors