title: How to set to int value null? Java Android
body: <p>which is the best way to set already defined <strong>int</strong> to <strong>null</strong>?</p>
  
  <pre><code>private int xy(){
      int x = 5;
      x = null; //-this is ERROR
      return x;
  }
  </code></pre>
  
  <p>so i choose this</p>
  
  <pre><code>private int xy(){
      Integer x = 5;
      x = null; //-this is OK
      return (int)x;
  }
  </code></pre>
  
  <p>Then i need something like :</p>
  
  <pre><code>if(xy() == null){
      // do something
  }
  </code></pre>
  
  <p>And my second question can i safely cast Integer to int?</p>
  
  <p>Thanks for any response.</p>