public class IncrementImpl implements Increment { private int delta; public IncrementImpl(int delta) { this.delta = delta; } /* * It is impossible to add an exception which has not been declared in a interface * except if it is a RuntimeException. */ public int increase(int i) throws TooSmallValueException { if (i < delta) { throw new TooSmallValueException(i); } return i + delta; } public static void main(String[] args) throws Exception { Increment o = new IncrementImpl(2); System.out.println(o.increase(5)); System.out.println(o.increase(-3)); } }