各位老兄帮个忙指点下以下程序的运算流程啦,我看了不怎么明的呢??
对个toSTring()方法一行般在什么时候被调用的呢?
//: Snake.java
// Tests cloning to see if destination of
// handles are also cloned.public class Snake implements Cloneable {
  private Snake next;
  private char c;
  // Value of i == number of segments
  Snake(int i, char x) {
    c = x;
    if(--i > 0){
      next = new Snake(i, (char)(x + 1));
}
  }
  void increment() {
    c++;
    if(next != null)
      next.increment();
  }
  public String toString() {
    String s = ":" + c;
    if(next != null){
      s += next.toString();
}
System.out.println(s);
return s;
  }
  public Object clone() {
    Object o = null;
    try {
      o = super.clone();
    } catch (CloneNotSupportedException e) {}
    return o;
  }
  public static void main(String[] args) {
    Snake s = new Snake(5, 'a');
    System.out.println("s = " + s);
    Snake s2 = (Snake)s.clone();
    System.out.println("s2 = " + s2);
    s.increment();
    System.out.println(
      "after s.increment, s2 = " + s2);
  }
} ///:~