第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

是不是做錯(cuò)了 感覺不對(duì)呢 大佬指點(diǎn)一下


是不是做錯(cuò)了 感覺不對(duì)呢 大佬指點(diǎn)一下https://img1.sycdn.imooc.com//5d240bd20001dc5406160212.jpg

https://img1.sycdn.imooc.com//5d240bd80001effb06390229.jpg

https://img1.sycdn.imooc.com//5d240bd80001e9c606210179.jpg

https://img1.sycdn.imooc.com//5d240bd800010d2906260194.jpg

https://img1.sycdn.imooc.com//5d240bdb0001660505620309.jpg



正在回答

3 回答

可以用構(gòu)造方法創(chuàng)建對(duì)象的時(shí)候往里面寫數(shù)據(jù),另外,父類的屬性子類可以直接用 this. 就行了

public Bus(Int people,String way){

this.people = people;

this.way = way;

}

//創(chuàng)建對(duì)象,和構(gòu)造方法對(duì)應(yīng)

Vehicle obj1 = new Bus(40,"公交");

obj1.Vway();

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

王大哈哈i 提問者

感謝
2019-07-09 回復(fù) 有任何疑惑可以回復(fù)我~
#2

唯進(jìn)

話說回來父類的方法也可以直接用,你子類重寫父類的方法沒有變動(dòng),那就沒有重寫的必要了
2019-07-09 回復(fù) 有任何疑惑可以回復(fù)我~
#3

唯進(jìn)

另外,你的父類屬性定的不太對(duì),你這么定義子類還有什么用..... 父類定義的屬性應(yīng)該是子類都有都有的屬性,所以放在父類子類就不用再寫一遍了,人數(shù)沒問題,但是way就很不對(duì)勁了。
2019-07-09 回復(fù) 有任何疑惑可以回復(fù)我~
#4

慕容0262671

Vehicle obj1 = new Bus(40,"公交");和Vehicle obj1 = new Bus("公交",40);輸出是一樣的嗎?
2019-08-28 回復(fù) 有任何疑惑可以回復(fù)我~
#5

慕容0262671

Vehicle obj1 = new Bus(40,"公交");和Vehicle obj1 = new Bus("公交",40);輸出是一樣的嗎?
2019-08-28 回復(fù) 有任何疑惑可以回復(fù)我~
查看2條回復(fù)
public?class?HelloWorld?{????public?int?people;????public?String?way;????public?void?Abc(){????????????System.out.println("交通工具為:"+way+"\n乘車人數(shù):"+people?????????????);????????????}???public?class?bus?extends?HelloWorld{????public???bus(int?people,String?way){	???this.people=people;???????this.way=way;??????this.Abc();????}???}public?class?run?extends?HelloWorld{????public???run(int?people,String?way){	???this.people=people;???????this.way=way;???????this.Abc();????}???}	public?static?void?main(String[]?args)?{????????		?		HelloWorld?num=new?HelloWorld();		bus?nums=num.new?bus(40,"公交");????????run?numss=nums.new?run(4,"跑步");	????	}}


0 回復(fù) 有任何疑惑可以回復(fù)我~

public class HelloWorld {

? ? public int people;

? ? public String way;

? ? public void Abc(){

? ? ? ?

? ? ?System.out.println("交通工具為:"+way+"\n乘車人數(shù):"+people? ? ? ? ? ? ?);

? ? ? ??

? ? }

? ?public class bus extends HelloWorld{

? ? public? ?bus(int people,String way){

? ?this.people=people;

? ? ? ?this.way=way;

? ? ? this.Abc();

? ? }


? ?}

public class run extends HelloWorld{

? ? public? ?run(int people,String way){

? ?this.people=people;

? ? ? ?this.way=way;

? ? ? ?this.Abc();

? ? }


? ?}





public static void main(String[] args) {

? ? ? ??

?

HelloWorld num=new HelloWorld();

bus nums=num.new bus(40,"公交");

? ? ? ? run numss=nums.new run(4,"跑步");

? ??

}

}


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

是不是做錯(cuò)了 感覺不對(duì)呢 大佬指點(diǎn)一下

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)