验证中...
Languages: Java
Categories: iOS 组件
Latest update 2019-03-27 15:37
gistfile1.txt
Raw Copy
interface Selector{
boolean end();
Object current();
void next();
}
public class Sequence{
private Object[]items;
private int next=0;
public Sequence(int size){items=new Object[size];}
public void add(Object x){
if(next<items.length)
items[next++]=x;
}
private class SequenceSelector implements Selector{
private int i=0;
public boolean end(){return i==items.length;}
public Object current(){return items[i];}
public void next(){if(i<items.length)i++;}
}
public Selector selector(){
return new SequenceSelector();
}
public static void main(String[]args){
Sequence se=new Sequence(10);
for(int i=0;i<10;i++)
se.add(Integer.toString(i));
Selector sele=se.seletor();
while(!sele.end()){
System.out.println(sele.current()+" ");
sele.next();
}
}
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search