Type Casting

 package typeCasting;


public class TypeCasting {


public static void main(String[] args) {

// Type Casting(Widening) Automatic Type Casting

byte x = 4;

int y = x;

double z = y;

System.out.println(x);

System.out.println(y);

System.out.println(z);


// Type Casting(narrowing) Manual Type Casting

double m = 2.12324;

int n = (int)m;

System.out.println(m);

System.out.println(n);

}

}


Comments

Popular posts from this blog

Arithmetic

Pattern 1