2020.8.28第五十三天

例9.6

 1 public class cjava {
 2     public static void main(String[] args) {
 3        Box b1=new Box(15,30,25);
 4        System.out.println(b1.height);
 5        Box b2=new Box(20,10,50);
 6        System.out.println(b2.height);
 7        System.out.println(b1.volume());
 8 }
 9 }
10 class Box{
11     int height;
12     int width;
13     int length;
14     Box(){
15         height=10;
16         width=10;
17         length=10;
18     }
19     Box(int h,int w,int len){
20         height=h;
21         width=w;
22         length=len;
23     }
24     int volume() {
25        return (height*width*length);
26     }
27 }

 2.遇到的问题:无

3.明天继续写例题

原文地址:https://www.cnblogs.com/Nojava/p/13579826.html