Untitled
By: a guest | Mar 22nd, 2010 | Syntax:
Java | Size: 0.83 KB | Hits: 95 | Expires: Never
import java.util.*;
public class iterator3 implements Iterator{
int tab[] = new int[100];
public int current,k,p;
public void GenerujTablice(){
for (int i=0; i<100; i++){
tab[i] = (int)(Math.random()*100);
System.out.print(" "+tab[i]);
if ( i % 10 == 0){
System.out.println("");
}
}
}
public void remove(){
try{}
catch(UnsupportedOperationException e){
System.err.println("Not supported.");
}
}
public void IterujTablice(int pe, int ka){
//Iterator it = new iterator3();
k=ka;
p=pe;
current=pe;
Iterator it = new iterator3();
while(it.hasNext()) {
it.next();
System.out.println("current"+current+" "+tab[current]);
}
}
public boolean hasNext(){
if(current < 100 ){
return true;} else {
return false;
}
}
public Object next(){
if(current < 99) {
current=current+k;}
return (Integer)tab[current];
}
}