/**实验3.3
* 实现矩形类其中包括计算矩形周长和面积的方法
**/
public class adu{ public static void main (String[] args) { Rectangle rectangle1 = new Rectangle (3, 12); Rectangle rectangle2 = new Rectangle (8, 21); System.out.println("rectangle1's perimeter : " + rectangle1.perimeter()); System.out.println("rectangle1's area : " + rectangle1.area()); System.out.println("rectangle2's perimeter : " + rectangle2.perimeter()); System.out.println("rectangle2's area : " + rectangle2.area()); }}class Rectangle{ private int length; private int width; Rectangle(int l, int w) { this.length = l; this.width = w; } int perimeter () { return (length + width) * 2; } int area () { return length * width; }}