刚写出来的,谢谢采纳
public class Number {
private int n1;
private int n2;
public Number(int n1, int n2) {
this.n1 = n1;
this.n2 = n2;
}
public int addition(){
return n1+n2;
}
public int subtration(){
return n1-n2;
}
public int multiplication(){
return n1*n2;
}
public int division(){
return n1/n2;
}
public static void main(String[] args) {
Number number = new Number(10, 2);
System.out.println(number.addition());
System.out.println(number.subtration());
System.out.println(number.multiplication());
System.out.println(number.division());
}
}
最后显示的结果是:
12
8
20
5