标签:length this 属性 pack class div his get int
package hm_4_19; public class Rectangle { public int length ; public int width; public Rectangle(int length, int width) { super(); this.length = length; this.width = width; } public int getArea() { // 面积 int area = length*width; return area; } public int getPer() { // 周长 int per = (length+width)*2; return per; } public void showAll() { // 所有属性 System.out.println("长"+length+"宽"+width+"面积"+getArea()+"周长"+getPer()); } public static void main(String[] args) { Rectangle r = new Rectangle(20, 30); r.showAll(); } }
标签:length this 属性 pack class div his get int
原文地址:https://www.cnblogs.com/wzm7282/p/12730775.html