zoukankan      html  css  js  c++  java
  • Java——子类对象实例化的全过程

    2.4子类对象实例化的全过程

    public class TestDog {

           public static void main(String[] args) {

                  Dog d = new Dog();

                  d.setAge(10);

                  d.setName("小明");

                  d.setHostName("花花");

                  System.out.println("name:" + d.getName() + " age:" + d.getAge()

                                + "hostName:" + d.getHostName());

                  System.out.println(d.toString());

           }

    }

    //生物

    class Creator {

           private int age;

           public int getAge() {

                  return age;

           }

           public void setAge(int age) {

                  this.age = age;

           }

           public Creator() {

                  super();

                  System.out.println("this is Creator's constructor");

           }

    }

    //动物类

    class Animal extends Creator {

           private String name;

           public String getName() {

                  return name;

           }

           public void setName(String name) {

                  this.name = name;

           }

           public Animal() {

                  super();

                  System.out.println("this is Animal's constructor");

           }

    }

    //

    class Dog extends Animal {

           private String hostName;

           public String getHostName() {

                  return hostName;

           }

           public void setHostName(String hostName) {

                  this.hostName = hostName;

           }

           public Dog() {

                  super();

                  System.out.println("this is Dog's constructor");

           }

    }

  • 相关阅读:
    java操作docker示例(docker-java)
    istio实现对外暴露服务
    istio实现自动sidecar自动注入(k8s1.13.3+istio1.1.1)
    k8s1.13.3安装istio(helm方式)
    wrk http压测工具介绍
    etcd 相关介绍
    openresty 常用API学习
    Lua 相关知识点
    Lua 获取table的长度
    Lua 字符串相关操作
  • 原文地址:https://www.cnblogs.com/superjishere/p/11819687.html
Copyright © 2011-2022 走看看