title: Cannot Find Symbol - method error
body: <p>I have a problem in this code.
  I have clearly written the method show() in the Bag class.
  But why is the compiler showing cannot find symbol for the method when I try to access the show method in the main()?</p>
  
  <pre><code>public class Bag1&lt;Item&gt; 
  {
  private int N;
  private Node&lt;Item&gt; first;
  
  public Bag1()
  {
      N = 0;
      first = null;
  }
  
  private class Node&lt;Item&gt;
  {
      private Item item;
      private Node&lt;Item&gt; next;
  }
  
  public void add(Item item)
  {
      Node&lt;Item&gt; oldfirst = first;
      first = new Node&lt;Item&gt;();
      first.item = item;
      first.next = oldfirst;
      N++;
  }
  
  public int size() 
  {
      return N;
  }
  
  public void show()  
  {
      Node&lt;Item&gt; oldfirst = first;
      while(first.next!=null)
      {
          System.out.println(first.item + " ");
          first = first.next;
      }
  }       
  public static void main(String[] args)
  {
      Scanner s = new Scanner(System.in);
      Bag&lt;String&gt; bag = new Bag&lt;String&gt;();
      while(s.hasNext())
      {   
          String item = s.next();
          if(!item.equals("-"))
              bag.add(item);
          else
              break;
      }
      bag.show();
      System.out.println("Size of the bag: " +bag.size());
  
  }
  }
  </code></pre>