标签:nbsp span stat 运行 inf lin 成员变量 void fir
public class test1 { String name; int age; public void te(String name, int age) { this.name = name; System.out.println(age); } public static void main(String[] args) { test1 a = new test1(); a.te("heel", 50); System.out.println(a.name); System.out.println(a.age); } }
此处this指当前对象,运行结果:
public class test1 { public void first() { System.out.println("first"); } public void second() { this.first(); //second方法调用first方法 System.out.println("second"); } }
public class test1 { public test1(String name){ } public test1(String a,int b) { this(a); //根据参数个数来调用本类中的构造方法 } }
标签:nbsp span stat 运行 inf lin 成员变量 void fir
原文地址:https://www.cnblogs.com/ddpapa/p/10717662.html