day09-继承中成员方法的访问特点
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.inmind.extends03;
|
||||
/*
|
||||
继承中成员方法的访问特点:在继承中访问成员方法时,new的是谁,就优先使用谁的成员方法,如果没有则向上找
|
||||
*/
|
||||
public class Demo03 {
|
||||
public static void main(String[] args) {
|
||||
Zi zi = new Zi();
|
||||
Fu fu = new Fu();
|
||||
|
||||
fu.methodFu();
|
||||
|
||||
zi.methodZi();
|
||||
zi.methodFu();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user