java错误在哪里?

来源:百度知道 编辑:UC知道 时间:2024/06/21 22:29:39
package book.basic;
public class ChangBasicType
{
private void forceChange()
{
double d=123.456d;
float f=(float)d;
long l=(long) d;
int i=(int)d;
short s=(short)d;
byte b=(byte)d;
System.out.print("d="+d+";f="+f+";l="+l+";i=");
System.out.println(+i+";s="+s+";b="+b);
}
public static void main(String[] args)
{
ChangeBasicType test=new ChangeBasicType();
test.forceChange();
}
}

public class ChangBasicType {
private static void forceChange() {
double d=123.456d;
float f=(float)d;
long l=(long) d;
int i=(int)d;
short s=(short)d;
byte b=(byte)d;
System.out.print("d="+d+";f="+f+";l="+l+";i=");
System.out.println(+i+";s="+s+";b="+b);
}
public static void main(String[] args) {
forceChange();
}
}

没这么强制转换的