fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. System.out.println("Java Narrowing Casting");
  11. double myDouble = 9.78d;
  12. int myInt = (int) myDouble; // Explicit casting: double to int
  13. System.out.println(myDouble);
  14. System.out.println(myInt);
  15. }
  16. }
Success #stdin #stdout 0.08s 36300KB
stdin
1
2
10
42
11
stdout
Java Narrowing Casting
9.78
9