联级调用
package 课堂4;
public class Mycounter {
private int a;
public Mycounter(int a)
{
this.a=a;
}
public Mycounter()
{
}
public Mycounter increase(int x)
{
this.a+=x;
return this;
}
public Mycounter decrease(int x)
{
this.a-=x;
return this;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Mycounter m1=new Mycounter(100);
System.out.println(m1.increase(20).decrease(40).a);
}
}