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

源代碼不能編譯應用

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

閱讀全文

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

熱點內容
python數組分片 瀏覽:251
linux圖形化編程 瀏覽:175
阿里國際站app端怎麼裝修 瀏覽:528
微信小程序雲開發簡單搭建源碼 瀏覽:851
以後缺程序員嗎 瀏覽:293
jsp源碼不能運行 瀏覽:363
淘客助手源碼下載 瀏覽:733
如何使用app記賬報稅 瀏覽:562
python線程捕捉鍵盤 瀏覽:25
地推統計圖app怎麼做 瀏覽:162
android文件夾不能用了 瀏覽:857
加密軟體的日誌 瀏覽:892
腎病pdf 瀏覽:230
網站怎麼用本地伺服器 瀏覽:120
javadoc導入android 瀏覽:517
文件掃描成pdf 瀏覽:696
涼山火災救援命令 瀏覽:54
壓縮機三相檢測 瀏覽:861
linux怎麼安裝光碟 瀏覽:799
寬頻伺服器無響應是為什麼 瀏覽:226