ListNode class:
  
class ListNode<T> {
    T data;
    ListNode<T> next;
   
    public ListNode(T data){
        this.data = data;
        next = null;
    }
   
    public ListNode(T data, ListNode<T> next){
        this.data = data;
        this.next = next;
    }
}
  
  
Write each of the following pure functions on ListNode.