跳动百科

rectangle函数参数(rectangle函数)

盛凝婵   来源:

大家好,我是小跳,我来为大家解答以上问题。rectangle函数参数,rectangle函数很多人还不知道,现在让我们一起来看看吧!

1、public class Rectangle {

2、public double len;

3、public double width;

4、public double getArea(double len,double width){

5、return len*width;

6、}

7、public double getLen() {

8、return len;

9、}

10、public void setWidth(double len) {

11、this.len = len;

12、}

13、public double getWidth() {

14、return width;

15、}

16、public void setWidth(double width) {

17、this.width = width;

18、}

19、public static void main(String[] args) {

20、Rectangle r = new Rectangle(40, 10);

21、System.out.println(r.getArea(r.getLen(), r.getWidth()));

22、}

23、}

本文到此讲解完毕了,希望对大家有帮助。