導航:首頁 > 源碼編譯 > 源代碼不能編譯應用

源代碼不能編譯應用

發布時間:2024-09-30 22:53:51

Ⅰ head first java專家術語學習機 源代碼為什麼不能編譯

首先,集合類(或者叫容器)不能放基本數據類型,必須是類。所以應把所有的ArrayList<int>改成ArrayList<Integer>;
其次,被private修飾的屬性(變數)都不能被其它類訪問,改成其它許可權即可。
import java.io.*;
import java.util.ArrayList;

public class SimpleDotComTestDrive{
public static void main(String[] args){
int numofguess=0;
GameHelper helper=new GameHelper();
SimpleDotCom theDotCom=new SimpleDotCom();
theDotCom.setLocationCells(theDotCom.locations);
boolean isAlive=true;
while(isAlive==true){
String guess=helper.getUserInput("enter a number");
String result=theDotCom.checkYourself(guess);
numofguess++;
if(result.equals("Kill")){
isAlive=false;
System.out.println("You took "+numofguess+" guesses");
}
}
}
}

class SimpleDotCom{
ArrayList<Integer> locations=new ArrayList<Integer>();
public String checkYourself(String userguess){
String result="miss";
int guess=Integer.parseInt(userguess);
int index=locations.indexOf(guess);
if(index>0){
locations.remove(index);
result="Hit";
}
if(locations.isEmpty()){
result="Kill";
}
System.out.println(result);
return result;
}
public void setLocationCells(ArrayList<Integer> a){
int randomnum1=(int)(Math.random()*5);
int randomnum2=randomnum1+1;
int randomnum3=randomnum2+1;
a.add(randomnum1);
a.add(randomnum2);
a.add(randomnum3);
}

}

class GameHelper{
public String getUserInput(String prompt){
String inputLine=null;
System.out.print(prompt+" ");
try{
BufferedReader is=new BufferedReader(new InputStreamReader(System.in));
inputLine=is.readLine();
if(inputLine.length()==0)
return null;
}
catch(IOException e){
System.out.println("IOException"+e);
}
return inputLine;
}
}

Ⅱ 源代碼未編譯什麼情況

這些語言在寫完後綴名是.c,這個時候要先編譯成.h,才能運行。
所以你保存後要先點編譯,然後才能點運行。
編譯鍵一般在運行鍵旁邊啦,你點擊了再看行不行,有時如果你的文件有錯誤,編譯的時候會報錯出現error和警告,只有程序是正確的,你才能編譯通過,再運行
七爪

Ⅲ [100分求解]:Dev-C++編譯.c文件時提示"源文件未編譯"無法運行 而把後綴改成.cpp後正常運行

原因:設置錯誤導致。解決方法:

如下參考:

1.首先,打開dev-c++,點擊菜單欄中的「工具」,點擊「編譯選項」,打開編輯選項對話框。

閱讀全文

與源代碼不能編譯應用相關的資料

熱點內容
單片機算交流 瀏覽:45
php自適應網站 瀏覽:467
2b2t伺服器怎麼獲得許可權 瀏覽:815
c語言javaphp 瀏覽:804
程序員技術不分高低嗎 瀏覽:619
dos不是內部或外部命令 瀏覽:708
PC機與單片機通訊 瀏覽:675
二級加密圖 瀏覽:113
壓縮機異音影響製冷嗎 瀏覽:711
德斯蘭壓縮機 瀏覽:490
程序員太極拳視頻 瀏覽:531
網上購買加密鎖 瀏覽:825
安卓為什麼軟體要隱私 瀏覽:83
虛擬主機管理源碼 瀏覽:811
java圖形圖像 瀏覽:230
單片機輸出口電平 瀏覽:486
java配置資料庫連接 瀏覽:479
java多態的體現 瀏覽:555
java的split分隔符 瀏覽:128
跪著敲代碼的程序員 瀏覽:239