zoukankan      html  css  js  c++  java
  • 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;



        //}

      }

  • 相关阅读:
    0x1L
    失败全是无能,成功多是侥幸。
    也谈不甘
    维护网站小笔记
    C#反射(二) 【转】
    C#反射(一) 【转】
    短期学习目标
    局域网手机遥控关机
    密码验证
    字符串反转
  • 原文地址:https://www.cnblogs.com/wuW00/p/4598996.html
Copyright © 2011-2022 走看看