日期:2014-05-20 浏览次数:20990 次
package com.longlizhi; public class Test1 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } } class Child { int no; Child nextChile; public Child(int no) { this.no=no; } } class CycLink { Child firstChild=null; Child temp; int len=0; public void setLen(int len) { this.len=len; } public void createLink() { for(int i=1;i<=len;i++) { if(i==1) { Child ch=new Child(i); this.firstChild=ch; this.temp=ch; } else { if(i==len) { Child ch=new Child(i); temp.nextChile=ch; temp=ch; temp.nextChile=this.firstChild; } else { Child ch=new Child(i); temp.nextChile=ch; temp=ch; } } } } }