public class juxing { double Chang; double Kuan; void M(double x1,double x2) { Chang = x1; Kuan=x2; double MianJi=Chang*Kuan; System.out.println("矩形的面积="+MianJi); } //属性 double chang1=22; double kuai2=11; public double MJ(double c1,double v1) { double a =c1; double b =v1; return a*b; } public class ceshi { public static void main(String[] args) { juxing S=new juxing(); S.M(23,11); System.out.println("长方形的面积是"+S.Chang*S.Kuan); //新的面积 juxing dx=new juxing(); dx.MJ(33, 44); System.out.println("新1的面积是="+dx.chang1*dx.kuai2); System.out.println("新2的面积是="+dx.MJ(33, 44)); } }
矩形的面积=253.0
长方形的面积是253.0
新1的面积是=242.0
新2的面积是=1452.0