?? interfacedemo4.java
字號:
// InterfaceDemo4.java
//接口shape
interface shape{
double PI=3.14159;
abstract double area();
}
//定義Rectangle類實現接口shape
class Rectangle implements shape{
double width,height;
public Rectangle(double w,double h){
width=w;
height=h;
}
public double area(){
return width*height;
}
}
//定義Circle類實現接口shape
class Circle implements shape{
double radius;
public Circle(double r){
radius=r;
}
public double area(){
return PI*radius*radius;
}
}
public class InterfaceDemo4{
public static void main(String args[]){
Rectangle rect=new Rectangle(15,20);
System.out.println("Rectanle area="+rect.area());
Circle cir=new Circle(10);
System.out.println("Circle area="+cir.area());
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -