title: Passing Null Integer as Parameter
body: <p>I have a method that takes an Integer <code>baz</code> as an optional parameter via overloading like so ...</p>
  
  <pre><code>public static void myMethod(String fooBar, Integer baz) {
  
      switch(baz){} // baz gets unboxed, NPE if it was null
  
      if(baz != null) {
          // Do something
      }
      else {
          // Do something else
      }
  }
  
  public static void myMethod(String fooBar) {
      myMethod(fooBar, null);
  }
  </code></pre>
  
  <p>However, it's giving me a warning about the <code>else</code> statement saying it's dead code.  But when the method is called without <code>baz</code>, <code>baz</code> should just default to <code>null</code> so this should not be dead code.  Any explanation as to what I'm doing wrong here?  How would <code>baz</code> always be non-null even though I set it to <code>null</code> in the overloaded method?</p>
  
  <p><strong>EDIT:</strong>  Deleted actual code so my question is easier to read.</p>