为啥调用不了
package com.imooc;
public class Telphone {
private float screen;
private float cpu;
private float mem;
public void sendMessage(){
System.out.println("send message。");
}
public float getScreen() {
return screen;
}
public void setScreen(float screen) {
this.screen = screen;
this.sendMessage();
}
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 Telphone(){
System.out.println("无参数的构造方法执行了");
}
public Telphone(float newScreen,float newCpu,float newMem){
if(newScreen<3.5f){
System.out.println("您输入的参数值有问题,自动赋值为3.5");
screen=3.5f;
}
else
{
screen=newScreen;
}
cpu=newCpu;
mem=newMem;
System.out.println("有参数的构造方法执行了screen:"+this.getScreen());
}
}
结果:
无参数的构造方法执行了
有参数的构造方法执行了screen:5.0
为什么没有显示send Message