相邻包不存在
Adjacent package does not exist
我在 Four\ Seasons\ Lab/things/Mountain.java
中有一个 public class Mountain
并尝试使用 import shapes.Triangle
导入 Four\ Seasons\ Lab/shapes/Triangle.java
中的 class public class Triangle
(注意:import shapes.*
也不起作用)。出于某种原因,每当我尝试使用 Triangle
class 时,它都会不断抛出 package shapes does not exist
以及 cannot find symbol
。我该如何解决这个问题?
Mountain.java
package things;
import shapes.Triangle;
import java.awt.Graphics;
import java.awt.Color;
public class Mountain {
private Triangle body;
public Mountain(int x, int y, int dx, int dy) {
this.body = new Triangle(
x, y + dy,
x + dx/2, y,
x + dx, y + dy
);
}
public void draw(Graphics g) {
body.draw(g);
}
}
Triangle.java
package shapes;
import java.awt.Graphics;
import java.awt.Color;
public class Triangle {
private Color color;
private int[] pointA;
private int[] pointB;
private int[] pointC;
public Triangle(Color color, int aX, int aY, int bX, int bY, int cX, int cY) {
this.color = color;
this.pointA = new int[] {aX, aY};
this.pointB = new int[] {bX, bY};
this.pointC = new int[] {cX, cY};
}
// more code
}
File Tree
Screenshot of Mountain.java
注:
Runner
将 运行 Scenery
,这将 运行 Mountain
- 程序必须运行在终端通过:
(in "Four Seasons Lab" directory)
$ javac *.java
$ java Runner
(通过仅包含 .java 文件的 .zip 文件共享)
问题不在于我的 IDE 或我的代码或任何东西。我使用 Atom 作为 IDE 和 linter-javac
包作为 linter。这只是 linter 的问题。
我在 Four\ Seasons\ Lab/things/Mountain.java
中有一个 public class Mountain
并尝试使用 import shapes.Triangle
导入 Four\ Seasons\ Lab/shapes/Triangle.java
中的 class public class Triangle
(注意:import shapes.*
也不起作用)。出于某种原因,每当我尝试使用 Triangle
class 时,它都会不断抛出 package shapes does not exist
以及 cannot find symbol
。我该如何解决这个问题?
Mountain.java
package things;
import shapes.Triangle;
import java.awt.Graphics;
import java.awt.Color;
public class Mountain {
private Triangle body;
public Mountain(int x, int y, int dx, int dy) {
this.body = new Triangle(
x, y + dy,
x + dx/2, y,
x + dx, y + dy
);
}
public void draw(Graphics g) {
body.draw(g);
}
}
Triangle.java
package shapes;
import java.awt.Graphics;
import java.awt.Color;
public class Triangle {
private Color color;
private int[] pointA;
private int[] pointB;
private int[] pointC;
public Triangle(Color color, int aX, int aY, int bX, int bY, int cX, int cY) {
this.color = color;
this.pointA = new int[] {aX, aY};
this.pointB = new int[] {bX, bY};
this.pointC = new int[] {cX, cY};
}
// more code
}
File Tree
Screenshot of Mountain.java
注:
Runner
将 运行Scenery
,这将 运行Mountain
- 程序必须运行在终端通过:
(in "Four Seasons Lab" directory)
$ javac *.java
$ java Runner
(通过仅包含 .java 文件的 .zip 文件共享)
问题不在于我的 IDE 或我的代码或任何东西。我使用 Atom 作为 IDE 和 linter-javac
包作为 linter。这只是 linter 的问题。