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

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

這里的newInstance可以換成new Documentbuilderfactory()嗎?

如題所示....這里不大懂,請(qǐng)教下

正在回答

2 回答

Documentbuilderfactory()是抽象類 不能夠直接被實(shí)例化 必須通過已實(shí)現(xiàn)的子類來創(chuàng)建對(duì)象 這里他直接有個(gè)newInstance()方法給你用 就相當(dāng)于是實(shí)例化了 所以就用這個(gè)


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

不行 下面是源碼

? protected DocumentBuilderFactory () {

? ? }

??public static DocumentBuilderFactory newInstance() {

? ? ? ? // instantiate the class directly rather than using reflection

? ? ? ? return new DocumentBuilderFactoryImpl();

? ?}

注意構(gòu)造方法是受保護(hù)的,也就是說不能直接new

要用newInstance


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

遺棄的八音盒 提問者

這樣設(shè)置代碼的意圖是什么?與直接用new不一樣?工廠模式那課程學(xué)了,但是也想不到這里為什么要這樣做....
2015-01-05 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

這里的newInstance可以換成new Documentbuilderfactory()嗎?

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

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

幫助反饋 APP下載

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

公眾號(hào)

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