java new子類(lèi)對(duì)象過(guò)程
導(dǎo)語(yǔ):Java是一門(mén)面向?qū)ο缶幊陶Z(yǔ)言,不僅吸收了C++語(yǔ)言的各種優(yōu)點(diǎn),還摒棄了C++里難以理解的多繼承、指針等概念,因此Java語(yǔ)言具有功能強(qiáng)大和簡(jiǎn)單易用兩個(gè)特征。下面我們來(lái)看看java new子類(lèi)對(duì)象過(guò)程,希望對(duì)大家有所幫助。
java new子類(lèi)對(duì)象過(guò)程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | class Fu { int num=8; Fu(){ System.out.println("Fu construction run"); show();/pic/code> } void show(){ System.out.println("Fu num----"+num); } /* { System.out.println("fu construction code"); }*/ } class Zi extends Fu{ int num=10;/pic/code> Zi(){/pic/code> super();/pic/code> /pic/code> /pic/code> System.out.println("zi construction run"); } void show(){/pic/code> System.out.println("Zi num。。。。。。"+num); } {/pic/code> System.out.println("Zi construction code run"); } } class JavaDemo{ public static void main(String[] args) { new Zi(); } } /* 此代碼運(yùn)行 結(jié)果 Fu construction run construction code run zi construction run Zi num。。。。。。10*/ |
【java new子類(lèi)對(duì)象過(guò)程】相關(guān)文章:
Java面向?qū)ο蠛兔嫦蜻^(guò)程的區(qū)別08-19
Java對(duì)象和類(lèi)11-09
Java面向過(guò)程教程09-04