實體類
Java代碼
public class Node {
public Node(){};
public Node(String name){
this
}
private String name;
public Node next;
public String getName() {
return name;
}
public void setName(String name) {
this
}
public Node getNext() {
return next;
}
public void setNext(Node next) {
this
}
}
調用
Java代碼
public static void invokeChainMethod(){
Node n = new Node()
n
n
Node nx = n;
while(true){
System
nx = nx
if(nx == null){
break;
}
}
} 說明
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25845.html