局部变量初始值
java会给成员变量赋初始值
不会给局部变量赋初始值
public class InitailPhone { String var = "成员变量"; void func(){ String var = "局部变量"; System.out.println(var); System.out.println(this.var);//访问成员变量时用this } public static void main(String[] args){ Telphone phone = new Telphone(); phone.screan = 14.5f; phone.call(); phone.sendMessage(); InitailPhone tphone = new InitailPhone(); tphone.func(); } }