Q:

addToRear method for Singly linked list

I am not sure if I am going about this the correct way, I simply want to implement the addToRear method in my Singly Linked List(generic for now), just have had mixed advice, so a little help? (Is this the correct way to implement the addToRear Method?)
 public void addToRear(T element) {
    T end = new T(newElement);
    if (head == null) 
         {head = end;} 

    }

A:

Try this..
 You create a Node type, that contain your Generic element..
public void addToRear(T element) {
    Node end = new Node(element);
    if (head == null){
        head = end;
    } else {
        Node temp = head;
        while(temp.next != null){
             temp = temp.next;
        }
        temp.next = end;
    }

}

