zoukankan      html  css  js  c++  java
  • java this

    this 代表什么

    this 应用场景

     https://docs.oracle.com/javase/tutorial/java/javaOO/thiskey.html

    When used as a primary expression, the keyword this denotes a value that is a reference to the object for which the instance method or default method was invoked , or to the object being constructed.

    The value denoted by this in a lambda body is the same as the value denoted by this in the surrounding context.

    Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called.

    You can refer to any member of the current object from within an instance method or a constructor by using this.

    你可以在实例方法或构造器中通过使用this来指明当前对象的任意成员。

    语法:

    He did not refer to the report from Australia.

    注意点:

    this 是对象的引用

    The most common reason for using the this keyword is because a field is shadowed by a method or constructor parameter.

    The keyword this may be used only in the following contexts:

    •  in the body of an instance method or default method

    •  in the body of a constructor of a class 

    •  in an instance initializer of a class

    •  in the initializer of an instance variable of a class

    •  to denote a receiver parameter

  • 相关阅读:
    近期总结
    input
    mysql语句
    同步与异步
    localStorage的增删查改封装函数
    最基本的前后台传值
    前段存储的调用函数
    js 控制弹出窗口的大小
    拖拽
    jQuery镇张缩小动画
  • 原文地址:https://www.cnblogs.com/zno2/p/5611296.html
Copyright © 2011-2022 走看看