/*
* 定义接口
*/
interface MyItfc {
public abstract double area(double area);
}
/*
* 类MyClass实现接口MyItfc
*/
public class MyClass implements MyItfc{
@Override
public double area(double area) {
double cube = Math.pow(area, 3);//计算area的立方
return cube;
}
public static void main(String[] args) {
//调用area()方法,打印出area的立方,此处结果为8.0
System.out.println(new MyClass().area(2.0));
}
}