java语言之this 关键字学习

      class Person3 {
         String name;
          int age;
          String address;
        Person3(){

      System.out.println("无参数的构造函数");
    }

   Person3(String name, int age){
    this.name = name;
    this.age = age;
    System.out.println("两个参数的构造函数" + " " + this.name + " " + this.age);

    }

    Person3(String name, int age, String address){
    this(name, age);//调用本类中参数为两个 name age 的函数.调用本类中的函数 必须放在第一位
    //this.name = name ;
    //this age = age;
    this.address = address;
    System.out.println("调用三个构造参数的函数" + " " + this.address);
    }

    //void talk() {
    //System.out.println(" 我的名字是 :" +"这里有一个this " + "this." + name);//哪个对象调用这个函数 this (this 就是对象)就代表那个对象,//函数无参数
    //可以省略,没有this 时 name 代表 参数中的name

    //}

    //void talk (String name, int age){
    //this name =name;
    //this age = age;



    //}

  }

原文地址:https://www.cnblogs.com/wuW00/p/4598996.html