Saturday 11 March 2017

Type Cast Program in java

By the end of this tutorial "Java Data Type Casting Type Conversion", you will be comfortable with converting one data type to another either implicitly or explicitly.

Program


  1. public class TypeCastProg
  2. {
  3.   public static void main(String[] args)
  4.   {
  5.      double x;
  6.      int y;
  7.      x=25.50;
  8.      System.out.println("Value of [double] x: "+x);
  9.      System.out.println("Conversion of double to integer");
  10.      y=(int)x;
  11.      System.out.println("Value of [integer] y: "+y);
  12.      int m;
  13.      double n;
  14.      m=10;
  15.      n=(double)m;
  16.      System.out.println("Value of [integer] m: "+m);
  17.      System.out.println("Conversion of integer to double");
  18.      System.out.println("Value of [double] n: "+n);

  19.   }
  20. }


No comments:

Post a Comment