zoukankan      html  css  js  c++  java
  • Extends 继承 (1)

    “Extends” simulates the relationship between the things in real world.
    父类: Superclass
    子类: Subclass
    A Java superclass is a class which gives a method or methods to a Java subclass. A Java class may be either a subclass, a superclass, both, or neither!

    ———-TestExtends.java———-
    package ch.allenstudy.newway02;

    public class TestExtends {
    public static void main(String[] args)
    {
    Graduate gd = new Graduate();
    System.out.printf(“%s %f\n”, gd.name, gd.score);
    }
    }

    class Human
    {
    public String name = “zhangsan”;
    public int age = 22;

    }

    class Student extends Human //学生,继承人类
    {
    public double score = 66.6;
    }

    class Graduate extends Student //研究生,继承学生
    {
    public String daoshi = “Allen”;
    }
    ——–Result——-
    zhangsan 66.600000

  • 相关阅读:
    二维数组排序
    php-快速排序
    sql优化相关
    全页面静态化缓存
    php--1-100相加之和
    php--阶乘
    socket
    posix_getpid 函数win下失效问题
    水仙花数
    常用的魔术方法
  • 原文地址:https://www.cnblogs.com/backpacker/p/2271555.html
Copyright © 2011-2022 走看看