I create a UnorderedLinkedList to split my sublist
public class UnorderedLinkedList<E extends Comparable<? super E>> extends LinkedList<E>
{
public void splitMid(LinkedList<E> subList)
{
Node<T> current;//the head pointer
Node<T> mid;//the mid point
//Node first = firstNode;
//Node last = firstNode;
//Node subListFirst;
//Node subListLast;
int i;
if(head == null)
{
subList.head = null;
subList.last = null;
subList.count = 0;
}
else
{
head = null;
current = head.next;
i = 1;
if(current != null)
current = current.next;
while(current != null)
{
mid = mid.next;
current = current.next;
i++;
if(current != null)
current = current.next;
}
subList.head = head.next;
subList.last = last;
last = mid ;
last.next = null;
subList.count = count - i;
count = i;
}
}
And when I compile it gave the error message that
G:\LinkedList\src\LinkedList.java:184: error: cannot find symbol
subList.count = 0;
symbol: variable count
location: variable subList of type LinkedList<E>.Node<T>
where T,E are type-variables:
T extends Object declared in class LinkedList
E extends Comparable<? super E> declared in class LinkedList.UnorderedLinkedList
In my main class
public void main(String args[])
{
LinkedList<Integer> myList = new LinkedList<Integer>();
LinkedList<Integer> subList = new LinkedList<Integer>();
myList.addLast(34);
myList.addLast(65);
myList.addLast(87);
myList.addLast(29);
myList.addLast(12);
JOptionPane optionPane = new JOptionPane();
String str1 = optionPane.showInputDialog(null, "show orignal LinkedList:" + myList);
myList.splitMid( subList);
String str2 = optionPane.showInputDialog(null, "show myList after calling splitMid:" + myList);
String str3 = optionPane.showInputDialog(null, "subList is:" + subList);
it gaves a error:
G:\LinkedList\src\LinkedTest.java:31: error: cannot find symbol
myList.splitMid( subList);
symbol: method splitMid(LinkedList<Integer>)
location: variable myList of type LinkedList<Integer>