1. public class Circle {
    2. float radius;
    3. public Circle(float cir_radius) {
    4. radius=cir_radius;
    5. }
    6. public float getArea() {
    7. return (float) (3.14*radius*radius);
    8. }
    9. public static void main(String[] args) {
    10. // TODO Auto-generated method stub
    11. Circle circle=new Circle(3);
    12. System.out.println("半径为3的圆面积为:"+circle.getArea());
    13. }
    14. }