我试图在一个单独的文件中创建一个Quadtree文件。
Quadtree<String> blocky = new Quadtree<String>(rand.nextInt(5), new Quadtree.Boundry(0,0,rand.nextInt(750),rand.nextInt(750)));
然而,我一直在终端中得到这个错误。
error: an enclosing instance that contains Quadtree.Boundry is required
当我在Boundry之前没有使用 "Quadtree. "时,我得到的是
error: cannot find symbol
有什么建议可以做吗?
编辑。
这是我的Quadtree类的一部分
import java.util.ArrayList;
public class Quadtree{
class Node{
int x, y;
E elem;
Node(int x, int y, E elem)
{
this.x = x;
this.y = y;
this.elem = elem;
}
}
final int QT_NODE_CAPACITY = 64;
int level = 0;
ArrayList<Node> nodes;
public Quadtree NW = null;
public Quadtree NE = null;
public Quadtree SE = null;
public Quadtree SW = null;
Boundry bdry;
public Quadtree(int level, Boundry bdry)
{
this.level = level;
this.bdry = bdry;
nodes = new ArrayList<Node>();
}
class Boundry
{
public int getXMin(){
return xMin;
}
public int getXMax(){
return xMax;
}
public int getYMin(){
return yMin;
}
public int getYMax(){
return yMax;
}
public Boundry(int xMin, int xMax, int yMin, int yMax)
{
super();
this.xMin = xMin;
this.xMax = xMax;
this.yMin = yMin;
this.yMax = yMax;
}
public boolean containsCoordinate(int x, int y)
{
return (x >= this.getXMin() && x <= this.getXMax() && y >= this.getYMin() && y <= this.getYMax());
}
int xMin, xMax, yMin, yMax;
}
Boundry
必须声明为 static
的实例化,而不需要将其限定在一个特定的实例上。Quadtree
.