package com.imooc;
public class Telephone {
public static void main(String[] args) {
// TODO Auto-generated method stub
Telephone phone = new Telephone();
phone.sendMessage();
phone.screen = 5.0f;
phone.cpu = 1.4f;
phone.mem = 2.0f;
phone.sendMessage();
}
}
未定义成员变量
package com.imooc;
public class Telephone {
float screen ;
float cpu ;
float mem ;
public void sendMessage(){
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Telephone phone = new Telephone();
phone.sendMessage();
phone.screen = 5.0f;
phone.cpu = 1.4f;
phone.mem = 2.0f;
phone.sendMessage();
}
}
没有定义属性吧,你就直接调方法,给赋值