I'm trying to make my add method work as you can see from my code below & it's giving me tremendous difficulty figuring out what's wrong with my code.
NodeFN class:
public class NodeFN {
    private String data; // Data for node.
    private NodeFN next; // Next node.
public NodeFN(String data) {
    this.data = data; // Take the data value passed in & store it in the data field.
    this.next = null; // Take the next node & store it in the next field.
}
// Mutator functions.
public String getData() {return data;}
public NodeFN getNext() {return next;}
public void setData(String d) {data = d;}
public void setNext(NodeFN n) {next = n;}
}
Queue class:
public class Queue {
    NodeFN head = null; // Head of node.
    public String n;
public Queue() {} // Default constructor.
public Queue(String n) { 
    head = new NodeFN(n); // head is now an object of NodeFN which holds a string.
}
public void add(String n) {
    NodeFN nn = new NodeFN(n); // nn is now an object of NodeFN which holds a string.
        if(nn == null) { // If the new node (nn) is empty.
            head = nn; // Then allow head to equal to the new node(nn).
        } else {
            // If new node (nn) alphabetically comes first compared to head 
            if(nn.getData().compareTo(head.getData()) < 0) { 
                nn.setNext(head); 
                head = nn;
            }       
        }
    }
public static void main(String[] args) {
    Queue q = new Queue();
    q.add("some string to test to see if it prints in console");
    System.out.println(q);
    }
}
 
     
     
     
    