class box {
double ht,wdt,len;
box(double h,double w,double l) {
ht=h;
wdt=w;
len=l;
}
double volume() {
return ht*wdt*len;
}
}
class boxme {
public static void main(String args[]) {
box mybox= new box(1,2,3);
System.out.print("The volume is "+mybox.volume());
}
}
//對於這個代碼在bluej中運行,我仍然需要在創建對象後給出參數(儘管我已經在我的代碼中給出了它們)。相同的代碼在cmd中運行良好,但顯示了這種差異當試圖在bluej.Please提供一個原因和解決方案,以帶出bluej和cmd之間的等價性? //用bluej編譯?
我強烈建議大寫首字母大寫的類名。不幸的是,我還沒有使用blueJ一段時間..我不是一個巨大的粉絲! – Arth 2012-04-14 18:50:51