java - 使用另一个文件中的类时,我不断收到一条错误消息,提示“找不到符号”
问题描述
我正在尝试在与我的四叉树文件不同的文件中创建四叉树。
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
当我在没有“四叉树”的情况下这样做时。在边界之前,我得到
error: cannot find symbol
关于我能做什么的任何建议?
编辑:
这是我的四叉树课程的一部分
import java.util.ArrayList;
公共类四叉树{
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
。
推荐阅读
- c - 在名称列表中查找最长的字符串
- python - 如何映射列以在 spark sql 数据框中创建新列?
- ios - MSAL 是否可用于在 ADFS for iOS 移动应用程序上使用基于证书的身份验证来实施 SSO?
- build - kdiff3 可下载的“kdiff3-1.8.5-windows-64-cl.exe” - 什么是“-cl”?
- python-3.x - 如何将数据写入 Django 临时文件?
- lighthouse - 如何修复 Lighthouse 错误:“警告:链接不可抓取”
- mysql - 如何在 MYSQL 的 INSERT 中选择 MAX() 以自动增加 customerNumber
- capybara - Capybara ingore 在指定断言的“范围内”
- javascript - WDIO - 本地和远程机器中的 isDisplayed() 方法差异
- android - 应用程序未部署在 Google Play 控制台中