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

源代碼不能編譯應用

發布時間: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++,點擊菜單欄中的「工具」,點擊「編譯選項」,打開編輯選項對話框。

閱讀全文

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

熱點內容
開發什麼手機app好 瀏覽:319
csgo如何在游戲里進入完美伺服器 瀏覽:190
編程教育老師成長心態 瀏覽:257
音頻採集單片機 瀏覽:590
加密管的優點 瀏覽:280
dock基礎命令 瀏覽:345
java編程愛好者 瀏覽:723
做外包程序員怎麼樣 瀏覽:865
程序員技術門檻 瀏覽:473
路由花生殼搭建web伺服器地址 瀏覽:541
小米傳送文件用什麼app 瀏覽:102
哪個領域演算法好 瀏覽:380
用命令行編譯java 瀏覽:677
筆趣閣app哪個是正版手機app 瀏覽:427
程序員這個工作好嗎 瀏覽:898
agps定位伺服器地址 瀏覽:659
用水做的解壓玩具怎麼做 瀏覽:418
安卓411能下載什麼 瀏覽:304
小海龜logo命令 瀏覽:493
java製作界面 瀏覽:895