4-6.txt

来自「java入门的几个代码,很实用,初学者不可错过」· 文本 代码 · 共 27 行

TXT
27
字号
class ColorPrint exends Point  //类ColorPoint是类Point的直接子类, 
//类Point是类ColorPoint的直接父类;
             //类Object是为ColorPoint的缺省父类,但不是直接父类
{
int color;
public static void draw()                //复盖了父类的draw()类
{ System.out.println("ColorPoint: a color point.")
}
}
class MapPoint extends ColorPoint    //类MapPoint是类Colorpoint的直接子类
{                               //类ColorPoint是类MapPoint的直接父类;
               //类Object、Point是为MapPoint的父类,但不是直接父类
String  name;            //地图上的点有自己的名字,如城市名
public  static void draw()     ////复盖了父类的draw()类
{ System.out.println("MapPoint: a map color point.")
}
}
public class SuperSub
{
public static void main(String args[])
{
Point.draw();          
Colorpoint.draw();
MapPoint.draw();
}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?