读代码: 1.packagefoo; 2.importjava.util.Vector; 3.privateclassMyVectorextendsVector{ 4.inti=1; 5.publicMyVector(){ 6.i=2; 7.} 8.} 9.publicclassMyNewVectorextendsMyVector{ 10.publicMyNewVector(){ 11.i=4; 12.} 13.publicstaticvoidmain(Stringargs[]){ 14.MyVectorv=newMyNewVector(); 15.} 16.} 结果是:
读代码: 1.packagefoo; 2.importjava.util.Vector; 3.privateclassMyVectorextendsVector{ 4.inti=1; 5.publicMyVector(){ 6.i=2; 7.} 8.} 9.publicclassMyNewVectorextendsMyVector{ 10.publicMyNewVector(){ 11.i=4; 12.} 13.publicstaticvoidmain(Stringargs[]){ 14.MyVectorv=newMyNewVector(); 15.} 16.} 结果是:
1