OnJava8-Examples/annotations/Multiplier.java
Bruce Eckel 88dbdbbbcb update
2015-05-18 23:05:30 -07:00

21 lines
513 B
Java

//: annotations/Multiplier.java
// javac-based annotation processing.
package annotations;
@ExtractInterface("IMultiplier")
public class Multiplier {
public int multiply(int x, int y) {
int total = 0;
for(int i = 0; i < x; i++)
total = add(total, y);
return total;
}
private int add(int x, int y) { return x + y; }
public static void main(String[] args) {
Multiplier m = new Multiplier();
System.out.println("11*16 = " + m.multiply(11, 16));
}
} /* Output:
11*16 = 176
*///:~