客户端是一个包含两个int变量的类。 我想使用我自己的方法“添加”(来自linkedList类)与defualt LinkedList“queue”,我该怎么做
public abstract class ClientQueue implements CQInterface{
Client c;
LinkedList<Client> queue = new LinkedList<Client>();
public void enqueue(Client c){
linkedList linkedList = new linkedList();
queue.linkedList.add(c);
}
class linkedList{
// reference to the head node.
private Node head;
private int listCount;
// LinkedList constructor
public linkedList()
{
// this is an empty list, so the reference to the head node
// is set to a new node with no data
head = new Node(null);
listCount = 0;
}
public void add(Object data)
{
Node temp = new Node(data);
Node current = head;
while(current.getNext() != null)
{
current = current.getNext();
}
current.setNext(temp);
listCount++;
}