1 public class juxing { 2 3 // 创建矩形类 4 5 // 属性 6 7 double chang; 8 9 double kuan; 10 11 // 方法 12 // 1 求面积 13 void mianji(double s) { 14 double k = chang * kuan; 15 16 System.out.println("矩形面积为" + k); 17 } 18 19 public static void main(String[] args) { 20 21 // 实例化矩形 22 juxing z = new juxing(); 23 24 z.chang = 8; 25 26 z.kuan = 6; 27 28 double k = 0; 29 z.mianji(k); 30 31 } 32 33 }