java继承实例基础
2024-10-21 06:47:25
总结:多态。重写。构造方法调用
package com.a; public class fsd { int a = 23; public fsd() {
System.out.println(44444444);
} public void txt(int a) {
System.out.println(a);
} } class yan extends fsd {
int b = 54; public yan() {
System.out.println(7);
} public void txt(int b) {
System.out.println(b);
}
} package com.a; public class Test {
public static void main(String[] args) {
// fsd s=new fsd();//调用父类无参数构造方法
// s.txt(2);//调用 子类的普通方法,方法重写,父类方法将被隐藏
fsd d = new yan();// 多态把所有不带参的构造方法调用了。父类和子类的。重写的只调用子类方法,父类方法将被覆盖
d.txt(21); } } 44444444
7
21
最新文章
- 自连接<;EntityFramework6.0>;
- angularJs之内置服务
- N久没写过东西了..写个最近在研究的程序
- oracle 职业学习指引
- hibernate查询方式
- CSS设置技巧
- (《数论及应用1.3》NEFU 116 两仪剑法(最小公倍数&;&;最大公约数))
- Gulp使用指南
- [leetcode] Combination Sum and Combination SumII
- vue.js 组件之间传递数据
- c++ 之模板进阶
- idea使用记录
- 欣赏<;沉默的大多数>;——王小波
- unity的一些tips
- c++命名空间---namespace
- mysql关联更新update
- vue总结 03过滤器
- angularjs获取元素以及angular.element()用法
- 虚拟IP和IP漂移
- C++实现:把一个文件夹里的冗余文件(.txt)删除