日期:2014-05-20 浏览次数:20764 次
class Circle{ private double redius,area,lenth; public double getArea(){ return Math.PI*redius*redius; } public double getLength(){ return 2*Math.PI*redius; } public void setRedius(double redius){ this.redius=redius; } } public class Try { public static void main(String[] args) { try{ Class cu=Class.forName("Circle"); Circle circle=(Circle)cu.newInstance(); circle.setRedius(100); System.out.println("圆的面积为:"+circle.getArea()); System.out.println("圆的周长为:"+circle.getLength()); } catch(Exception e){ System.out.println("不能加载"+e.getMessage()); } } }