aaarong
发贴: 24
积分: 0
|
于 2007-04-22 08:51
interface jiekou{ void f1(); }
class number1 implements jiekou{ double x1,y1; number1(double u1,double v1){x1=u1;y1=v1;} public void f1(){System.out.println(x1+"平方的值是"+x1*x1); System.out.println(y1+"平方的值是"+y1*y1); } }
class number2 implements jiekou{ double x2,y2; number2(double u1,double v2){x2=u1;y2=v2;} public void f1(){System.out.println(x2+"立方的值是"+x2*x2*x2); System.out.println(y2+"立方的值是"+y2*y2*y2); } } public class A_1_2_3_4{ public static void main(String []args){ number1 pf1=new number1(2.0,3.0); number2 lf2=new number2(2.0,3.0); jiekou jiekouSet[]={pf1,lf2}; for(int i=0;i<jiekouSet.length;i++) jiekouSet[i].f1(); } } 给你点意见: > 做为一名程序员, 独立思考,善于专研是最基本的品质 加油.......
|