This is based on LinkedLists. Please complete the methods max()and threshold(). I'd greatly appreciate it. There is a typemismatch in my first method and I dont know how to get around it.I've commented on the line with the type mismatch. Please write acorrect method in the answer so I can compare it to my wrongmethod
public class Node {
  public T info;
public Node link;
public Node(T i, Node l) {
  info = i; link = l;
  }
}
class LinkedList> {
 Â
protected Node head = null;
public LinkedList add(T el) {
head = new Node(el, head);
return this;
}
public void print() {
for(Node node = head; node!=null; node=node.link) {
System.out.print(node.info+\" \");
}
System.out.println(\"\");
}
 Â
public T maxValue() { // Note: Recursive methods not allowed, usingnew key word not allowed, no iterators allowed
  if (head == null) {
  return null;
  }
  else {
  Node temp = head;
  if (temp.link == null) {
  return temp.info;
  }
  else {
  T max = temp.link; //type mismatch
  if (temp.info.compareTo(max) > 0)
  max = temp.info;
  return max;
  }
}
}
 Â
public void threshold(T thres) {//Note: Recursive methods notallowed, using new key word not allowed, no iterators allowed
}
public static void main(String args[]) {
 Â
LinkedList list = new LinkedList();
System.out.println(list.maxValue()); // should be null
list.add(20).add(30).add(10);
System.out.println(list.maxValue()); // should be 30
list.threshold(40);
list.print(); // should print out all elements
list.threshold(30);
list.print(); // should print out 10 20
list.threshold(10);
list.print(); // should print nothing
}
}