//测试this关键字的使用方法
public class thisDemo {
String eat = "午饭时间";
String tea = "下午茶时间";
int i = 16;
public void eat(int i) {
if (i > 11 && i < 14) {
System.out.println("现在是" + i + "点," + eat);
} else if (i > 14 && i < 18) {
System.out.println("现在是" + i + "点," + tea);
}
}
public void tea(int i) {
if (this.i > 11 && this.i < 14) {
System.out.println("现在是" + this.i + "点," + eat);
} else if (this.i > 14 && this.i < 18) {
System.out.println("现在是" + this.i + "点," + tea);
}
}
public static void main(String[] args) {
thisDemo demo = new thisDemo();
demo.eat(12);
demo.tea(12);
}
}
【Everyday】___ 测试this关键字的使用方法
最新推荐文章于 2021-02-04 12:40:05 发布