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

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

這個(gè)為什么會(huì)報(bào)錯(cuò)?

這個(gè)為什么會(huì)報(bào)錯(cuò)?創(chuàng)建了一個(gè)父類Celphone,一個(gè)子類phone。在創(chuàng)建對(duì)象時(shí),只有父類能創(chuàng)建,子類創(chuàng)建的時(shí)候就報(bào)錯(cuò)了,請(qǐng)問這是什么意思???

package equal;


public class Initial {


public static void main(String[] args) {

// TODO Auto-generated method stub

Celphone phone1=new Celphone();

phone phone=new Phone();

phone1.Screen=6;

phone1.Cpu=5;

phone1.Mum=4;

Celphone phone2=new Celphone();

phone2.Screen=6;

phone2.Cpu=5;

phone2.Mum=4;

if(phone1.equals(phone2)){

System.out.println("兩者相同");

}else{

System.out.println("兩種不同");

}

}


正在回答

2 回答

你這段代碼不合理,

package equal;


public class Initial {


public static void main(String[] args) {

// TODO Auto-generated method stub

Celphone phone1=new Celphone();

phone phone=new Phone();

phone1.Screen=6;

phone1.Cpu=5;

phone1.Mum=4;

Celphone phone2=new Celphone();

phone2.Screen=6;

phone2.Cpu=5;

phone2.Mum=4;

if(phone1.equals(phone2)){

System.out.println("兩者相同");

}else{

System.out.println("兩種不同");

}

}

在我表明的下劃線那里,你應(yīng)該改成Phone phone = new Phone();

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

慕碼人2389635 提問者

非常感謝!
2016-09-27 回復(fù) 有任何疑惑可以回復(fù)我~

第五行phone phone=new Phone();應(yīng)該寫成Phone phone = new Phone();

類類型規(guī)范是要求大寫首字母的,這個(gè)屬于筆誤。

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

慕碼人2389635 提問者

好像不是這個(gè)問題啊。報(bào)錯(cuò)的理由是Exception in thread "main" java.lang.Error: Unresolved compilation problems: Phone cannot be resolved to a type Phone cannot be resolved to a type at equal.Initial.main(Initial.java:8)
2016-09-27 回復(fù) 有任何疑惑可以回復(fù)我~
#2

奮斗小青年974 回復(fù) 慕碼人2389635 提問者

就是這個(gè)問題,類的聲明時(shí),首字母必須讀寫,這是java編碼的規(guī)范,你在Eclipse,創(chuàng)建class文件,只有首字母大寫才能創(chuàng)建成功
2016-10-23 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Java入門第二季 升級(jí)版
  • 參與學(xué)習(xí)       531098    人
  • 解答問題       6280    個(gè)

課程升級(jí)!以終為始告別枯燥,在開發(fā)和重構(gòu)中體會(huì)Java面向?qū)ο缶幊痰膴W妙

進(jìn)入課程

這個(gè)為什么會(huì)報(bào)錯(cuò)?

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

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

幫助反饋 APP下載

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

公眾號(hào)

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