62,614
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
int i = 5;
float f =3.5f;
double b;
float f1;
f1 = i * f;//若int和float的运算结果为double,则需要像下面那样强制类型转换
b = i * f;
f1 = (float) b;
}
public class Test {
public void test(float f) {
System.out.println("float");
}
public void test(double d) {
System.out.println("double");
}
public void test(int i) {
System.out.println("int");
}
public static void main(String[] args) {
Test t = new Test();
int i = 10;
float f = 10f;
t.test(f * i);
}
}
输出结果为float