什么是“本”指的是在Android SDK中的参数? [英] What does 'this' mean as a parameter in Android SDK?

查看:170
本文介绍了什么是“本”指的是在Android SDK中的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  什么是本在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
    }

}

这篇关于什么是“本”指的是在Android SDK中的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆