Returning to my main ADT material here, and trying to kill two birds with one stone, learning Java, while I'm trying to write a simple merge sort algorithm with a common linked list (which I create myself). It turned out to be much more complicated than I imagined! Can someone help me please? I will begin work on the basics and will update this post until I get further access.
My code for a generic linked list is as follows:
public class NodeList<T> {
private Comparable head;
private NodeList tail;
public NodeList( Comparable item, NodeList list ) {
head = item;
tail = list;
}
}
I am trying to access this class in another class that I made, which looks like this:
public class MyList<T> {
private NodeList<T> nodes;
private int size;
public MyList( ) {
nodes = null;
}
public MyList(T[] array ){
for(int countArray = 0; countArray <= array.length() ; countArray++) {
nodes= new NodeList( value, nodes );
size++;
}
}
which should add common elements from the array using a linked list. Unfortunately, this is not the case, and this is the first problem I have encountered. I get an error message:
: length().
- , ?
!