title: Java instanceof not match Double
body: <p>I have a <code>Value</code> Class and there is an <code>Object value</code> in it. I want to use the value as <code>String</code>, <code>Integer</code> or <code>Double</code>.</p>
  
  <p>The <code>asDouble</code> method controls <code>instanceof</code> value object. If it is not <code>Double</code> or <code>Integer</code> returns <code>0</code>.</p>
  
  <p>Generally it works but sometimes although it is <code>Double</code> <code>returns 0;</code>. I couldn't the reason of it.</p>
  
  <p>When I debug I can see:</p>
  
  <p><a href="https://i.stack.imgur.com/FE6e1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FE6e1.png" alt="you can check"></a></p>
  
  <p>Here is my Value class</p>
  
  <pre><code>public class Value{
      public Object value;
  
      public Value(Object value) {
          this.value = value;
      }
  
      public Double asDouble() {
          if (this.value instanceof Integer || this.value instanceof Double) {
              return Double.parseDouble(String.valueOf(this.value));
          } else {
              return 0.0; 
          }
      }
  }
  </code></pre>
  
  <p>Could anybody explain where did I go wrong</p>