數(shù)據(jù)類型為啥明明強(qiáng)制轉(zhuǎn)換了還會(huì)錯(cuò)
public class HelloWorld{
? ? public static void main(String[] args) {
double heightAvg1=176.2;
int heightAvg2=(int)heightAvg1;
System.out.println(heightAvg1);
System.out.println(heightAvg2);
}
}
輸入上面的代碼出現(xiàn)以下錯(cuò)誤error: cannot find symbol
int heightAvg2=inrheightAvg1;
^
symbol: variable inrheightAvg1
location: class HelloWorld
1 error
2016-08-08
error: cannot find symbol
int heightAvg2=inrheightAvg1;
^
symbol: variable inrheightAvg1
location: class HelloWorld
1 error
意思是在"int heightAvg2=inrheightAvg1;"這一行中,
你把變量名寫錯(cuò)了,編輯器找不到"inrheightAvg1"這個(gè)變量在哪
正確的寫法是"int heightAvg2=(int)heightAvg1;"
你再檢查一下,如果按照你上面的那些代碼,是不應(yīng)該出現(xiàn)這個(gè)錯(cuò)誤提示的,
或者有可能是你把代碼改好了,但是沒有保存,所以編輯器報(bào)錯(cuò)。
2015-10-26
代碼沒問題 你是不是用的imooc練習(xí)器 他提示你錯(cuò)誤 那應(yīng)該是網(wǎng)絡(luò)延時(shí)的問題
2015-10-26
在我電腦上能夠運(yùn)行。