title: why i get NullPointerException when i try to visit member variables after force type convert?
body: <p>I create a class <code>Node</code> which contains an int variable <code>val</code>
  When I try to get the <code>val</code> after I pop it from stack, the compiler throw a <code>NullPointerException</code>. 
  Does anyone knows how to fix this?</p>
  
  <pre><code>public class Node{
    int val;
    Node left;
    Node right;
    Node(int x) {val = x;}
  }
  
  
  Node root = new Node(6);
  Stack s = new Stack();
  s.push(root);
  Node node = (Node)s.pop();
  System.out.println(node.val);
  </code></pre>