今天写了个乘积运算函数,小笔记录一下:
public class Multiplier {
public int multiply(int x, int y) {
int total = 0;
//11*16相当于11个16相加
for (int i = 0; i < x; i++){
total += y;
System.out.println(total);
}
return total;
}
public static void main(String[] args) {
Multiplier m = new Multiplier();
System.out.println("11*16 = " + m.multiply(11, 16));
}
}