花之慶次 2009-9-28 02:05
	有一個程式問題想請教一下
class BMW_Serial
{
    private int carLength, enCC, maxSpeed;
    public String modelName;
    public void ShowData()
    {
       carLength=423;
       engCC=3000;
       maxSpeed=250;
       System.out.println(modelName+ "基本資料");
       System.out.println("車身長度:" +carLength);
       System.out.println("氣缸CC數:" +engCC);
       System.out.println("最高車速:" +maxSpeed);
    }
}
    public class Ch1_02 extends BMW_Serial
    {
       public Ch1_02(String name)
       {
            modelName=name;
       }
       public static void main(String args[])
       {
            Ch1_02 BMW318=new Ch1_02("BMW 318i");
            BMW318.ShowData();
       }
    
}
問題主要是engCC=3000;  以及System.out.println("氣缸CC數:" +engCC);這兩個語句不知道出了什麼問題, 以下是執行結果:
Ch1_02.java:8: cannot find Symbol
Symbol:variable engCC
Location class BMW_Serial
engCC=3000;
^
Ch1_02.java:12:Cannot find Symol
Symol:variable engCC
Location:class BMW_Serial
System.out.println("氣缸CC數:" +engCC);
                                                  ^
有沒有人知道這是什麼意思呢????
[[i] 本帖最後由 花之慶次 於 2009-9-28 02:09 編輯 [/i]]
 
	jayzhou_2046 2009-10-3 01:10
	變數宣告的時候用的是enCC
private int carLength, enCC, maxSpeed
ShowData()中, 用的是engCC
 
	babylon1234 2009-10-22 23:49
	*** 作者被禁止或刪除 內容自動屏蔽 ***
 
	jaijai1 2009-11-19 01:52
	[align=right][float=right][url=][color=#000000][打開廣告][/color][/url][url=][color=#000000][隱藏廣告][/color][/url] 
[/float][/align]
[版主清空內容]
[[i] 本帖最後由 jayzhou_2046 於 2009-11-20 22:24 編輯 [/i]]
 
	manutd88888888 2009-11-20 00:42
	*** 作者被禁止或刪除 內容自動屏蔽 ***
 
	bluehorse_fun 2009-12-1 02:50
	private int carLength, [color=red]enCC[/color], maxSpeed
用的是enCC, not engCC