class Typecast {
public static void main(String args[]) {
byte h = 127;
int a = 300;
float a1 = 12.222 f;
float g;
short b = 200;
long c = 999999;
float e = 345.89 F;
double f = 45645.78222222222222;
g = (float) f;
System.out.println("short b =" + g);
System.out.println("short b =" + b);
System.out.println("long c =" + c);
System.out.println("float e=" + e);
System.out.println("double f=" + f);
System.out.println("short b=" + b);
System.out.println("short to byte " + (byte) b);
System.out.println("int to byte " + (byte) a);
System.out.println("int to float" + (float) a);
System.out.println("long to byte " + (byte) c);
System.out.println("double to long " + (long) f);
System.out.println("double to int " + (int) f);
System.out.println("double to byte " + (byte) f);
System.out.println("double to short " + (short) f);
System.out.println("double to float " + (float) f);
System.out.println("float to int " + (int) e);
System.out.println("float to byte " + (byte) e);
System.out.println("float to short " + (short) e);
System.out.println("float to long " + (long) e);
System.out.println("float to double =" + (double) e);
System.out.println("long to int" + (int) c);
System.out.println("byte to int =" + (int) h);
}
}
public static void main(String args[]) {
byte h = 127;
int a = 300;
float a1 = 12.222 f;
float g;
short b = 200;
long c = 999999;
float e = 345.89 F;
double f = 45645.78222222222222;
g = (float) f;
System.out.println("short b =" + g);
System.out.println("short b =" + b);
System.out.println("long c =" + c);
System.out.println("float e=" + e);
System.out.println("double f=" + f);
System.out.println("short b=" + b);
System.out.println("short to byte " + (byte) b);
System.out.println("int to byte " + (byte) a);
System.out.println("int to float" + (float) a);
System.out.println("long to byte " + (byte) c);
System.out.println("double to long " + (long) f);
System.out.println("double to int " + (int) f);
System.out.println("double to byte " + (byte) f);
System.out.println("double to short " + (short) f);
System.out.println("double to float " + (float) f);
System.out.println("float to int " + (int) e);
System.out.println("float to byte " + (byte) e);
System.out.println("float to short " + (short) e);
System.out.println("float to long " + (long) e);
System.out.println("float to double =" + (double) e);
System.out.println("long to int" + (int) c);
System.out.println("byte to int =" + (int) h);
}
}
|
No comments:
Post a Comment