方法构建Leaf increment()
public class Leaf {private int i=0;
public Leaf increment(){
i++;
return this;
}
void print(){
System.out.println("i="+i);
}
public static void main (String []args){
Leaf x=new Leaf();
x.increment().increment().increment().increment().print();
}
}
这里的Leaf increment() 可以换成public void increment()吗,请附带原因
补充:Java , Java相关