关于this关键字的简单使用

 1 package testBlog2;
 2 class A{
 3     int i = 0;
 4     A(int j){
 5         this.i = j;//this相当于"本类"的意思.这里指使本类中的变量i等于传入的j
 6     }
 7 }
 8 public class Test2 {
 9     public static void main(String[] args) {
10         A a = new A(2);//在这里,通过实例化修改了类中变量i
11         System.out.println(a.i);//结果输出2
12     }
13 }
原文地址:https://www.cnblogs.com/ssC2H4/p/8185607.html