package chapter2;
public class Telephone02 {
private float screen;
private float cpu;
private float mem;
public float getScreen() {
return screen;
}
public void setScreen(float screen) {
this.screen = screen;
}
public float getCpu() {
return cpu;
}
public void setCpu(float cpu) {
this.cpu = cpu;
}
public float getMem() {
return mem;
}
public void setMem(float mem) {
this.mem = mem;
}
public Telephone02() {
System.out.println("无参的构造方法执行了!");
}
public Telephone02(float newscreen,float newcpu,float newmem) {
screen=newscreen;
cpu = newcpu;
mem = newmem;
System.out.println("有参的构造方法执行了!");
}
}
这个Telephone02 类是供其他类调用的,在其他类中定义一个main方法,来实例化Telephone02