第一个方法使用this就是下边的运行效果,不适用this,需要把//去掉,并且在原来//下边一行的句首加上//,从两次输出结果表明带有this的Induce()可以反复调用,否则不可以
/*create a class with two function;
* methods:the first function induce the second one twice* second with keyword this but first without;
*/
public class Test8 {
int sum=0;
//void Induce(){Addin();}
Test8 Induce(){Addin();return this;}
void Addin(){sum++;}
public static void main(String[] args) {
Test8 f=new Test8();
//f.Induce();System.out.println(f.sum);
System.out.println(f.Induce().Induce().Induce().sum);
}
}