为什么我的输出会是四行?
package yi.bao.com;
public class Telphone {
//属性(成员变量)有什么
float screen;
float cpu;
float mem;
int var;
//方法 干什么
void call(){
System.out.println("var"+var);
System.out.println("screen:"+screen+"cpu:"+cpu+"mem"+mem+"Telphone有打电话的功能");
}
void sendMessage(){
System.out.println("var"+var);
System.out.println("screen:"+screen+"cpu:"+cpu+"mem"+mem+"Telphone有发短信的功能");
}
}
package yi.bao.com;
public class InitailTelphone {
public static void main(String[] args) {
// TODO Auto-generated method stub
// 类名 对象名 = new 类名
Telphone phone = new Telphone();
//对象方法
phone.sendMessage();
phone.call();
//给实例变量赋值
phone.screen = 5.0f;
phone.cpu = 1.4f;
phone.mem = 2.0f;
//调用对象方法
phone.call();
phone.sendMessage();
}
}