package a; public class Chongzai { private int i; private int j; private int k; int m; public int getI() { return i; } public void setI(int i) { this.i = i; } public int getJ() { return j; } public void setJ(int j) { this.j = j; } public int getK() { return k; } public void setK(int k) { this.k = k; } public int getM() { return m; } public void setM(int m) { this.m = m; } public void cheng(int i,int j) { m=i*j; } public void cheng(int i,int j,int k) { m=i*j; } public int cheng() { m=i*j; return m; } }
package C; import a.Chongzai; public class A { public static void main(String[] args) { Chongzai a1=new Chongzai(); a1.setI(2); a1.setJ(3); a1.cheng(); System.out.println("m="+a1.getM()); a1.cheng(3, 4); System.out.println("m="+a1.getM()); a1.cheng(5, 6, 7); System.out.println("m="+a1.getM()); } }