So I need a linked list to store multiple variables, so I want to use my hand-made Linked List ADT, but also want Java's Linked List's Comparator Sort from collections.sort();
So I tried and edited my code as following:
public class HLinkedList <HTreeNode> extends LinkedList <HTreeNode>
{
public class HTreeNode {
public HTreeNode left;
public HTreeNode right;
public HTreeNode next;
public int frequency;
public char value;
public String code;
public HTreeNode(int freq, char val, HTreeNode l, HTreeNode r, HTreeNode n, String code) // code is the path taken to this node, how to explain it in code?
{
value = val;
frequency = freq;
left = l;
right = r;
next = n;
code = ""; // just initialized ,but have to think through logic.
}
}
but if I do this, instead of just public class HLinkedList
(which is fine except I can't use Collections.sort(HList, comparatorA)
, one line of code that I need to have Java's Linked List for.
anyways, if I have my code as shown above it returns a
cannot make static reference to non-static type HTreeNode in following line,
with red lining under HTreeNode. This does not happen if I do not try to extend LinkedList.
public static void insertIntoPosition(HTreeNode node, int position)
also following the above error is an error in
public HLinkedList() //constructor
{
head = null; //inital value
nItem = 0;//counter
}
where multiple occurences in the code indicate they cannot static reference a non-static head. Usually when stuff like this comes up I click "make that head static", but in this case when I do that even more errors pop up, now pointing to ALL the "head" references.
I would just like to know what is going on when I am trying and failing at extending LinkedList, or if I'm supposed to not extend but do something else maybe?