Rect u = new Rect(3.5f, 4.5f);

2023-06-13  本文已影响0人  哈迪斯Java

public class Rect {
private float height;
private float width;

public Rect(float height, float width) {
    this.height = height;
    this.width = width;
}

public float square() {
    return height * width;
}

public static void main(String args[]) {
    Rect u = new Rect(3.5f, 4.5f);
    System.out.println(u.square());
}

}

public class Demo {
private Demo() {

}

public static Demo getInstance() {
    return new Demo();
}

}

上一篇下一篇

猜你喜欢

热点阅读