什么是“本”指的是在Android SDK中的参数?指的是、参数、Android、SDK

由网友(别伤害我老婆)分享简介:可能重复:结果  什么是本在Java中的意义? 我还是很新的学习的Andr​​oid编程,我注意到,这种被经常使用的参数,在语言的方法调用。我下面通过YouTube新波士顿的教程,但他从来没有真正解释相当不够详细是什么'这个'语句的意思。可有人请解释一下?也许哑下来一点?I'm still very new to...

可能重复:结果  什么是本在Java中的意义?

我还是很新的学习的Andr​​oid编程,我注意到,这种被经常使用的参数,在语言的方法调用。我下面通过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
    }

}
阅读全文

相关推荐

最新文章