1.求长方体的体积要求类中用但参数的方法去求
public class Cjava { public static void main(String[]args) { Box b1=new Box(12,20,25); System.out.println("体积为:"+b1.volume()); Box b2=new Box(10,14,20); System.out.println("体积为:"+b2.volume()); } } class Box { int l,w,h; Box(int a,int b,int c){ l=a;w=b;h=c; } int volume() { return l*w*h; } }
2.没问题
3.明天继续写例题