日期:2014-05-20 浏览次数:20685 次
class Circle
{
private static double pi = 3.14;
private double radius;
public Circle (double r)
{
radius = r;
}
public static double compare(Circle[] cir)
{
int max = 0;
for(int x=1;x<cir.length;x++)
{
if(cir[x].radius>cir[max].radius)
max = x;
}
return cir[max].radius;
}
}
class Demo
{
public static void main(String[] args)
{
Circle cir[] = new Circle[3];
cir[0] = new Circle(1.0);
cir[1] = new Circle(2.0);
cir[2] = new Circle(4.0);
System.out.println(Circle.compare(cir));
}
}
cir[0] = new Circle(1.0);
cir[1] = new Circle(2.0);
cir[2] = new Circle(4.0);