title: Using linked lists with boolean methods
body: <p>I need to create a PhoneBook using a linked list that contains multiple boolean  methods.One of those is insert that is susposed to enter a new Person in the PhoneBook, if the Person already exists the method phonebook shouldnt change.I am having trouble implementing this method, particullarly at the part where I'm supposed to compare the name the user inputs, with the one that is already in the phonebook.This is my code</p>
  
  <pre><code>class PhoneBookList implements PhoneBook {
      private int size = 0;
      Node head;
  
      private static final class Node {
          final Person person;
          Node next;
  
          Node(Person person) {
              this.person = person;
          }
      }
  
      public boolean insert(Person person) {
          Node n = new Node(person); 
          Node p = head,prev = null;
  
  
          if(p == null) {
              head = n;
              size++;
              return true;
          }
  
          int comparison = p.name.compareTo(n.name);
  
          if(comparison &lt; 0) {
              n.next = p;
              p = n;
              size++;// 
              return true;
          }
  
          if(comparison == 0) {
              return false;
  
          }
  
          Node current = p;
          while(current.next !=null &amp;&amp; current.next.person &lt; person) {
              current = current.next;
          }
          if(current.next !=null &amp;&amp; current.next.person == person) {
              return false;
  
          }
  
          n.next = current.next;
      current.next = n;
          size++;
      return true;
      }
  }
  </code></pre>
  
  <p>We have to explicitly use this compareTo method,and I cannot get it to work.Any guidance.Here are the errors:</p>
  
  <pre><code>PhoneBookList.java:25: error: cannot find symbol
                  int comparison = p.name.compareTo(n.name);
                                                     ^
    symbol:   variable name
    location: variable n of type Node
  PhoneBookList.java:25: error: cannot find symbol
                  int comparison = p.name.compareTo(n.name);
                                    ^
    symbol:   variable name
    location: variable p of type Node
  PhoneBookList.java:40: error: bad operand types for binary operator '&lt;'
                  while(current.next !=null &amp;&amp; current.next.person &lt; person) {
                                                                   ^
    first type:  Person
    second type: Person
                                                                   ^
    first type:  Person
    second type: Person
  </code></pre>
  
  <p>Thank you!          </p>