实例化函数的具体步骤
来源:互联网 发布:深圳金地物业评价知乎 编辑:程序博客网 时间:2024/04/29 15:31
1、找父类的无参构造函数
1.1、初始化成员变量
1.2、实现构造函数中的方法体
2、回到元类,并依次实现1.1和1.2
3、注:this()、super(),位于构造函数第一位,语义是调用相应的构造函数
this、super可任意在方法体中的位置调用,语义是调用相应方法和属性
package com.jacob.javase.extend;public class Parent { int age; String username="xieji"; public void getUsername(){ System.out.println("parent username"); } public Parent() { System.out.println("Parent wucan constructor"); } public Parent(int i) {// this(); System.out.println("Parent youcan constructor"); }}
package com.jacob.javase.extend;public class Child extends Parent{ String username="jacob"; public void getUsername(){ System.out.println("child username"); } public Child() { super(1); System.out.println("child wucan constructor"); System.out.println(super.username); super.getUsername(); } public Child(int i) { System.out.println("child ycan constructor"); } }
package com.jacob.javase.extend;public class Test { public static void main(String[] args) { new Child().getUsername(); System.out.println(new Child().username);}}
0 0
- 实例化函数的具体步骤
- 内核裁剪的具体步骤
- 安装Tomcat的具体步骤
- DH建模的具体步骤
- 安装windowsXP IIS_setup的具体步骤
- ssh搭建时的具体步骤
- Linux内核裁剪的具体步骤
- Linux内核裁剪的具体步骤
- Linux内核裁剪的具体步骤
- Linux内核裁剪的具体步骤
- Linux内核裁剪的具体步骤
- 安全设置MSSQL的具体步骤
- Linux内核裁剪的具体步骤
- Linux内核裁剪的具体步骤
- Linux内核裁剪的具体步骤
- fckeditor的使用具体步骤1
- 添加对话框AlertDialog的具体步骤
- 存储过程开发的具体步骤
- 面试题
- 阿里毕玄:我在系统设计上犯过的14个错
- Listview ViewPager 解决滑动冲突
- MySQL数据类型
- 现场直击:中国人的数据库分支AliSQL开放源代码下载 功能新增秒杀场景优化、TokuDB
- 实例化函数的具体步骤
- “交接”完成 iOS 10 的安装率已经超过 iOS 9
- C#注释&调试_161017
- Gitblit 2
- Java消息摘要算法
- 中国人的数据库分支:ApsaraDB AliSQL 开源思路
- Java通过JDBC实现对数据库的增删查改(预编译方式)
- CirBuffer
- Java基本类型与包装类