自学JVAVA---(16)--(内功心法【14】)this

    xiaoxiao2025-05-17  5

    this 混沌世界两茫茫,一丝明镜悬房梁。 this观己红尘凉,捂手扪心称帝王。 在这个喧嚣的尘世中有多少人可以认清自己呢 this代表当前对象

    public class ThisDemo { String name; Integer age; ThisDemo(){ System.out.println("ThiDemo"); } ThisDemo(String name , Integer age){ //this 调用构造器必须在第一行 this(); //this可以区分自己的属性和参数 this.age = age; this.name = name; System.out.println("argument"); } public static void main(String[] args) { ThisDemo td = new ThisDemo("GuoLiCheng",22); } }
    最新回复(0)