我试图找到一个解决方案来解决我在eclipse中运行的编译错误,但是如果我尝试在终端中编译它就不行。
以下是我开始编写的两个课程
load.java
package doom;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
public class load {
public int row;
public int columns;
private char[][] world;
public load() throws IOException{
BufferedReader file01 = new BufferedReader(new FileReader("map1.txt"));
int rows = 0;
while((file01.readLine()) != null){
rows++;
}
world = new char[rows][];
}
public void getMap() throws IOException{
BufferedReader file01 = new BufferedReader(new FileReader("map1.txt"));
String line;
int i = 0;
while((line=file01.readLine()) != null){
world[i++] = line.toCharArray();
}
System.out.println(Arrays.deepToString(world));
System.out.println(world[4][6]);
file01.close();
}
}
start.java
package doom;
import java.io.IOException;
public class start {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
load world = new load();
world.getMap();
}
}
这是我尝试在终端中编译时遇到的错误。
138-38-157-112:tet ciaranashton$ javac start.java
start.java:9: error: cannot find symbol
load world = new load();
^
symbol: class load
location: class start
start.java:9: error: cannot find symbol
load world = new load();
^
symbol: class load
location: class start
2 errors
答案 0 :(得分:0)
您需要拥有load.class
个文件,因为start.java
指的是load.java
。
首先编译load.java
,您的程序将正常运行。