this表示当前对象,所谓当前对象,就是调用类中属性或方法的那个对象。
/**
* Created by xabcd on 2019/2/16.
*/
public class total_this
{
class total{
private String name;
private int age;
public void total(String name,int age)
{
this.name = name;
this.age = age;
}
public String talk()
{
return "我是:"+this.name+"今年"+this.age+"岁";
}
}
public static void main(String args[])
{
total t = new total("张三", 33);
System.out.println(t.talk());
}
}
