public class Rectangle { public int length; public int width; public Rectangle(int length,int width){ } public int area(int length,int width){ this. length=length; this. width=width; return length*width;} public int zhangchang(int a,int b){ a=length; b=width; return 2*(length+width); } /** * @param args */ public static void main(String[] args) { int k; int j; // TODO Auto-generated method stub Rectangle m=new Rectangle(2,5); k=m.area(2,5); j=m.zhangchang(2, 5); System.out.println("面积是"+k+"周长是"+j); } }
使用构造方法和调用成员方法计算圆的面积和周长
最新推荐文章于 2021-01-16 01:00:30 发布