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;



        //}

      }

  • 相关阅读:
    Cannot get a NUMERIC value from a STRING cell? 已解决
    Android Studio快捷键大全
    mysql索引
    eclipse中出现错误 Syntax error, insert "}" to complete Block
    function
    IGS OPC UA 配置
    IFIX 5.9 历史数据 曲线 (非SQL模式)
    IFIX 5.9 报警存sql
    IFIX 数据源 节点 标签 域名
    IFIX 目录结构
  • 原文地址:https://www.cnblogs.com/wuW00/p/4598996.html
Copyright © 2011-2022 走看看