title: ClassCastException Integer to Double
body: <p>Why this code throws this exception:</p>
  
  <pre><code>public class DS3{
      public static void main(String[] args) {
          double r = (double)((Object)4);
          System.out.println(r);          
      }   
  }
  </code></pre>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ClassCastException:
    java.lang.Integer cannot be cast to java.lang.Double</p>
  </blockquote>
  
  <p>And this, just run fine:</p>
  
  <pre><code>public class DS4{
          public static void main(String[] args) {
              double r = (double)(4);
              System.out.println(r);          
          }   
      }
  </code></pre>
  
  <p>Both are a attempt to convert integer to double, right?</p>