Hi
I have a linked list class whose nodes contain a linked list;
I'm doing this like so;
class KeywordList{
private Node head;
public KeywordList() {
head = null;
}
public void addKeyword(
String newrule) {
Node current,previous,newNode;
(initialize stuff here)
RuleList rule = new RuleList();
(use a method here from RuleList to add to Rule List)
newNode = new Node(newkey, rule, current);
newNode.display();
}
class Node {
String keyword;
int occurrences;
Node next;
RuleList rule;
Node(String newkey, RuleList rule, Node newLink) {
keyword = new String(newkey);
rule = new RuleList();
occurrences = 1;
next = newLink;
}
public void display(){
RuleList.Iterator RuleRetriever = rule.new Iterator();
System.out.println("Keyword " + keyword);
while (RuleRetriever.hasMoreRules()) {
System.out.print("from display ");
System.out.println(String.valueOf(RuleRetriever.nextItem()));}
}
(methods for Node class follows and Iterator class)
The problem I'm having is that I am unable to access the rule parameter of Node from the display method. My toString method and compareTo method has no problem getting keyword or occurrences but trying to access the rule, yields null.
This is really making my brain bleed. Any help will go long way in avoiding an aneurisym.
Thanks
Dominique