慕粉1118315922
2020-04-19 21:57
package exercise1;
public class Staff {
float screen ;
float cpu;
float mem;
public Staff(float newScreen,float newCpu,float newMem) {
screen = newScreen;
cpu = newCpu;
mem = newMem;
System.out.println("有参的构造方法");
}
}
package exercise1;
public class player {
public static void main(String[]args) {
Staff staff = new Staff();
new Staff(5.0f,1.4b,3.0g);
}
}
5.0 , 1.4 , 3.0后边的那个字母f是代表float,表示单精度
........ 正确写法是 Staff staff= new Staff( 5.0f, 1.4f,3.0f);
Java入门第二季 升级版
530715 学习 · 6091 问题
相似问题