"this"的含义是什么?以下语句中的关键字? [英] what is the meaning of "this" keyword in below statement?

查看:99
本文介绍了"this"的含义是什么?以下语句中的关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

runner = new Thread(this,threadName)

runner = new Thread(this, threadName)

推荐答案

此处. [ ^ ]


Java中的关键字"this"的含义与C#和C ++中的完全相同,并且与VB.NET和Delphi中的"self"相同.

这是对可通过非静态方法(也称为实例方法)访问的类型的实例(对象)的引用.从技术上讲,与静态方法/属性相比,它作为附加的隐式参数传递给实例方法或属性.

由于这在命名语言中是完全一样的,因此请查看我过去有关C#和C ++的答案中对它的工作方式的解释:
什么使静态方法可访问? [第22章-接口对象的指针在功能消失时消失使用它们是静态的. [ ^ ].

—SA
The keyword "this" in Java means exactly the same as in C# and C++ and, say, the same as "self" in VB.NET and Delphi.

This is a reference to the type''s instance (object) accessible by a non-static method (also called instance method). Technically, it is passed to instance method or property as an additional implicit parameter, in contrast to static methods/properties.

As this is exactly the same thing in the named languages, please see my explanation of how it works in my past answers about C# and C++:
What makes static methods accessible?[^],
Catch 22 - Pointers to interface objects die when function using them is made static.[^].

—SA


这篇关于"this"的含义是什么?以下语句中的关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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