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

源代碼不能編譯應用

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

閱讀全文

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

熱點內容
伸展pdf 瀏覽:321
清遠dns的伺服器地址是多少 瀏覽:596
mac查看命令路徑 瀏覽:123
命令行關閉埠 瀏覽:652
加密頻道收視 瀏覽:484
java的GUI組件 瀏覽:656
怎麼查詢化妝品牌的真偽app 瀏覽:861
單機化命令 瀏覽:550
使用adb命令導出日誌 瀏覽:901
富貴包正骨按摩解壓視頻 瀏覽:816
電腦硬碟夾怎麼加密 瀏覽:628
dosping命令 瀏覽:856
源代碼不能編譯應用 瀏覽:734
文件加密寶怎麼用 瀏覽:384
優勢命令模式 瀏覽:546
小程序前端防反編譯 瀏覽:453
要如何連接手機的伺服器 瀏覽:779
遊客app怎麼樣 瀏覽:394
空調壓縮機焊接 瀏覽:338
數控編程中怎麼擴孔 瀏覽:960