400 028 6601

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

浅谈Java中this的使用(转)

浅谈 Java 中 this 的使用(转)[@more@]  1. this是指当前对象自己。

  当在一个类中要明确指出使用对象自己的的变量或函数时就应该加上this引用。如下面这个例子中:
CODE:
public class A {

String s = "Hello";

public A(String s) {
System.out.println("s = " + s);
System.out.println("1 -> this.s = " + this.s);
this.s = s;
System.out.println("2 -> this.s = " + this.s);
}

public static void main(String[] args) {
new A("HelloWorld!");
}
}

当前文章:浅谈Java中this的使用(转)
文章地址:http://mbwzsj.com/article/jjjhdp.html
  • 网站建设专属方案

  • 网站定制化设计

  • 7X24小时服务

  • N对管家服务

让你的专属顾问为你服务