title: cannot find symbol variable ... V extends Object declared in class
body: <p>I'm practising Java for school, and I'm in trouble now.</p>
  
  <p>This is my Graph.java file:</p>
  
  <pre><code>package graph;
  
  public interface Graph&lt;V&gt;{
      public boolean hasEdge(V one, V two);
      public void addNode(V other);
      public void addEdge(V other);
  }
  </code></pre>
  
  <p>And this is my UndirectedGraph.java file:</p>
  
  <pre><code>package graph.undirected;
  
  import graph.*;
  import java.util.*;
  
  public class UndirectedGraph&lt;V&gt; implements Graph&lt;V&gt;{
  
      private HashMap&lt;V,V&gt; neighbourList;
      private TreeMap&lt;V,V&gt; prev;
      private TreeMap&lt;V,Integer&gt; dist;
  
      public UndirectedGraph(){
          neighbourList = new HashMap&lt;V,V&gt;();
          prev = new TreeMap&lt;V,V&gt;();
          dist = new TreeMap&lt;V,Integer&gt;();
      }
  
      public boolean hasEdge(V one, V two){
          if(!(this.neighbourList.containsKey(one) &amp;&amp; this.neighbourList.containsKey(two))){
              throw new java.util.NoSuchElementException("Nonexistent node.");
          }
          else{
              if( one.neighbourList.containsKey(two) &amp;&amp; two.neighbourList.containsKey(one) ){
                  return false;
              }
              return true;
          }
      }
      public void addNode(V other){
          if(!(this.neighbourList.containsKey(other))){
              // some code will come here
          }
      }
      public void addEdge(V other){
          if(!(this.neighbourList.containsKey(other))){
              // and some code will come here too
          }
      }
  }
  </code></pre>
  
  <p>And I got the following errors:</p>
  
  <blockquote>
    <p>graph\undirected\UndirectedGraph.java:23: error: cannot find symbol
                            if( one.neighbourList.containsKey(two) &amp;&amp; two.neighbourList.containsKey(one) ){
                                   ^   symbol:   variable neighbourList   location: variable one of type V   where V is a type-variable:
        V extends Object declared in class UndirectedGraph graph\undirected\UndirectedGraph.java:23: error: cannot find symbol
                            if( one.neighbourList.containsKey(two) &amp;&amp; two.neighbourList.containsKey(one) ){
                                                                         ^   symbol:   variable neighbourList   location: variable two of type V<br>
    where V is a type-variable:
        V extends Object declared in class UndirectedGraph 2 errors</p>
  </blockquote>
  
  <p>And I'm stuck here. Can anyone help me?</p>