class Person{
public void eat(Apple apple){
Apple peeled=apple.getPeeled();
System.out.println("Yummy");
}
}
class Peeler{
static Apple peel(Apple apple){
return apple;
}
}
class Apple{
Apple getPeeled(){
return Peeler.peel(this);
}
}
public class PassingThis{
public static void main(String[] args){
new Person().eat(new Apple());
}
}
这个this指的哪里啊?
public void eat(Apple apple){
Apple peeled=apple.getPeeled();
System.out.println("Yummy");
}
}
class Peeler{
static Apple peel(Apple apple){
return apple;
}
}
class Apple{
Apple getPeeled(){
return Peeler.peel(this);
}
}
public class PassingThis{
public static void main(String[] args){
new Person().eat(new Apple());
}
}
这个this指的哪里啊?
解决方案 »
- 关于PriorityQueue不得不说的事
- spring mvc中
- short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错?
- 关于JTable的回车事件
- 求使用Java在内存中生成每通道16位或32位的图像,及对其进行操作和显示的方法。
- 有点小问题,希望各位兄台给看看,我是个新人,渴望以后能多交流。
- 请问我想用eclipse开发jsp不知该下什么插件?在哪里下?
- 用socket 传中文字串 乱码问题。
- 请问这段有关接口的英文怎么理解?SCJP
- Java初学者,请教Java反射问题
- 急求高手的解答?(答者有分)
- 关于hashMap使用内存的一个问题
楼主【Mengmengenator】截止到2008-06-22 16:30:07的历史汇总数据(不包括此帖):
注册日期:2007-5-14
上次登录:2008-6-22
发帖数:0 发帖分:0
结贴数:0 结贴分:0
结贴率:100%结分率:100%
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
Apple apple;
apple.getPeeled(),那么在这个函数调用中,函数里的这个this,就是指的apple这个对象!
new Person().eat(new Apple());
this就是上一句的new Apple
这是Java编程思想上的一个程序
我校网站上有视频讲解