Friday, February 10, 2017

Testowy post

Raz dwa trzy

Trochę kodu:
import java.util.Iterator;
/**
 * the fibonacci series implemented as an Iterable.
 */
public final class Fibonacci implements Iterable {
  /** the next and previous members of the series. */
  private int a = 1, b = 1;

  @Override
  public Iterator iterator() {
    return new Iterator() {
      /** the series is infinite. */
      public boolean hasNext() { return true; }
      public Integer next() {
        int tmp = a;
        a += b;
        b = tmp;
        return a;
      }
      public void remove() { throw new UnsupportedOperationException(); }
    };
  }