其他分享
首页 > 其他分享> > 面向对象_03

面向对象_03

作者:互联网

package day01;

/*

*/
public class UserTest {
public static void main(String[] args) {
User u1 = new User();
System.out.println(u1.name );//null
System.out.println(u1.age);//0
System.out.println(u1.isMale );//false

	u1.talk("日语");
	
}

}
class User{
//属性(成员变量)
String name;
int age;
boolean isMale;

public void talk (String language) {//language:形参,也是局部变量
	System.out.println("我们使用"+language + "进行交流");
}

public void eat() {
	String food = "烙饼";
	System.out.println("北方人喜欢吃:+food");
	
}

}

标签:03,局部变量,System,面向对象,println,属性,public,out
来源: https://www.cnblogs.com/horizonblue/p/16482015.html