title: String Peek( ) method in a Stack in java
body: <p>I'm doing a string type stack in Java and I want to know how is the peek method please. This is my peek but int type:</p>
  
  <pre><code>public int Peek()
  {
     NodoOperaciones nodo;
     int dato;
     nodo = getCabeza();
     dato = nodo.getData();
     return dato;
  }
  </code></pre>
  
  <p>and if I change int for String it throws me a Null Pointer Exception. Thanks.</p>