简体   繁体   English

关于“此”用法

[英]About “this” usage

I am studying Java language. 我正在学习Java语言。

When I studied about keyword this , I wonder if I can allocate other object to this . 当我研究关键字this ,我想知道是否可以this分配其他对象。

for example, If I make a method that its parameter is an object, Can I make a current object refer a parameter object using this keyword? 例如,如果我使一个方法的参数为对象,是否可以使当前对象使用this关键字引用参数对象?

No you can't. 不,你不能。 In a sense this is implicitly final : ie it cannot be changed to refer to a different object. 从某种意义上说, this是隐式的final ,不能更改它以引用另一个对象。

Also, you can't deviate from the language's definition of this . 同样,您不能偏离语言对this的定义。 It's a keyword so therefore cannot be used for anything else. 这是一个关键字 ,因此不能用于其他任何内容。

You cannot, this is a Java Keyword. 您不能,这是Java关键字。

Look at the oracle site for all keywords. oracle网站上查找所有关键字。

Here is a list of keywords in the Java programming language. 这是Java编程语言中的关键字列表。 You cannot use any of the following as identifiers in your programs. 您不能在程序中使用以下任何一种作为标识符。 The keywords const and goto are reserved, even though they are not currently used. 关键字const和goto被保留,即使它们当前未使用。 true, false, and null might seem like keywords, but they are actually literals; true,false和null可能看起来像关键字,但它们实际上是文字。 you cannot use them as identifiers in your programs. 您不能在程序中将它们用作标识符。

The this keyword in Java is much like the I word in english. Java中的this关键字很像英语中的I字。 It is obviously insane to image that you can point this at a different object in the same way you cannot make " I am wearing a blue shirt " to imply the colour of anyones shirt than your own. 这显然是疯狂的形象,你可以点this在你不能让“ 我穿着一件蓝色衬衫 ”意味着任何人的衬衣比你自己的颜色以同样的方式不同的对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM