JAVA(MyEclipse)总是报错。请高手指点!

来源:百度知道 编辑:UC知道 时间:2024/09/22 05:43:14
package s1java.xmal1;

public class Map {
public static void main(String[]args){
int[] map = new int[100];
int[] luckyTurn = {6, 23,40, 55, 69, 83};
int[] landMine = {5, 13, 17, 33, 38, 50, 64, 80, 94};
int[] pause = {9, 27, 60, 93};
int[] timeTunnel = {20, 25, 45, 63, 72, 88, 90};

public void createMap(){
int i = 0;
for(i = 0; i < luckyTurn.length; i++){
map[luckyTurn[i]] = 1;
}
for(i = 0; i < landMine.length; i++){
map[landMine[i]] = 2;
}
for(i = 0; i < pause.length; i++){
map[pause[i]] = 3;
}
for(i = 0; i < timeTunnel.length; i++){
map[timeTunnel[i]] = 4;
}
}
public String getGraph(int i, int index, int playerPos1, int playerPos2){
String graph = "";
if(index == playerPos1 && index== playerPos2){
graph = "@@";
}else if(index == player

主方法里面不能在定义方法
也就是不能在方法里面在定义方法
要把其他的方法定义在main方法的外面
定义成static 的可以在main 里直接使用

安装的时候进行默认安装基本没什么问题,如果不是默认安装有时候会出错误

我怎么感觉像在做 飞行旗呢?

showMap 这个方法 的括号 你确定没 扩错么?

应该是这样的吧

public void showMap(int playerPos1, int playerPos2){
showLine1(0, 31, playerPos1, playerPos2);
System.out.println();
showRLine(31, 35, playerPos1, playerPos2);
showLine2(35, 66, playerPos1, playerPos2);
System.out.println();
showLLine(66, 69, playerPos1, playerPos2);
showLine2(69, 100, playerPos1, playerPos2);
}
}

君不见你的左大括号和右大括号的个数不一样么?!
System.out.println();
showRLine(31, 35, playerPos1, playerPos2);
showLine2(35, 66, playerPos1, playerPos2);
System.out.println();
showLLine(66, 69, playerPos1, playerPos2);
showLine2(69, 100, playerPos1, playerPos2);

最后的这几行,不在