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.
- public class TypeCastProg
- {
- public static void main(String[] args)
- {
- double x;
- int y;
- x=25.50;
- System.out.println("Value of [double] x: "+x);
- System.out.println("Conversion of double to integer");
- y=(int)x;
- System.out.println("Value of [integer] y: "+y);
- int m;
- double n;
- m=10;
- n=(double)m;
- System.out.println("Value of [integer] m: "+m);
- System.out.println("Conversion of integer to double");
- System.out.println("Value of [double] n: "+n);
- }
- }
No comments:
Post a Comment