什么是“本”指的是在Android SDK中的参数? [英] What does 'this' mean as a parameter in Android SDK?
问题描述
可能重复:结果
什么是本在Java中的意义?
我还是很新的学习的Android编程,我注意到,这种被经常使用的参数,在语言的方法调用。我下面通过YouTube新波士顿的教程,但他从来没有真正解释相当不够详细是什么'这个'语句的意思。可有人请解释一下?也许哑下来一点?
I'm still very new to learning Android programming, and I noticed that "this" was used often in parameters for method calls in the language. I'm following The New Boston tutorials through YouTube, but he never really explains quite detailed enough what the 'this' statement means. Can somebody please explain it to me? Maybe dumb it down a bit?
推荐答案
这个
是指当前正在内编码类的实例。
this
refers to the instance of the class you are currently coding within.
您可以在静态情况下,因为在这种情况下,你都没有任何对象上下文中不能使用它。因此,这个
不存在。
You cannot use it in a static context because in this situation you are not within any object context. Therefore this
doesn't exist.
public class MyClass {
public void myMethod(){
this.otherMethod(); // Here you don't need to use 'this' but it shows the concept
}
private void otherMethod(){
}
public static void myStaticMethod(){
// here you cant use 'this' as static methods don't have an instance of a class to refer to
}
}
这篇关于什么是“本”指的是在Android SDK中的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!