public class Example_1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
byte b=22;
int n=129;
float f=123456.789f;
double d=123456789.123456789;
System.out.println("b="+b);
System.out.println("n="+n);
System.out.println("f="+f);
System.out.println("d="+d);
b=(byte)n;
f=(float)d;
System.out.println("b="+b);
System.out.println("f="+f);
}
}
运行结果:
b=22
n=129
f=123456.79
d=1.2345678912345679E8
b=-127
f=1.23456792E8