我从 Eclipse 调试器中收到以下错误:局部变量不可用。试图尽可能地修剪代码。问题很简单,我必须使用 Divise 类中的 DivisiveUI UpdateLog() 方法,使用 Cluster 类中的变量。Divise 有一个包含所有集群的列表。Divisive 和 DivisiveUI 相互引用。如何访问 Divisive 类中的变量:sumDistance、avgDistance?尝试在 Divisive 类中编写方法,仍然无法访问所需的变量:| 谢谢!
在 log.append(text+"\n"); 未找到源。
分裂:
package clusters;
import java.util.LinkedList;
public class Divisive implements Runnable
{
LinkedList<Record> mainTable;
LinkedList<Cluster> clusterList;
int meassureType;
DivisiveUI parent;
int clusterCount;
Divisive(LinkedList<Record> mainTable, DivisiveUI parent)
{
this.parent=parent;
this.mainTable=new LinkedList<Record>(mainTable);
setMeassureType(0);
}
}
分裂UI:
package clusters;
@SuppressWarnings("serial")
public class DivisiveUI extends JPanel implements Runnable{
ClusteringSelection parent;
Divisive divisive;
JTextField clusterCount;
JTextArea log;
public void UpdateLog(String text)
{
log.append(text+"\n");
log.setCaretPosition(log.getDocument().getLength());
}
}
簇:
package clusters;
public class Cluster
{
LinkedList<Record> table;
LinkedList<MatrixRow> matrix;
LinkedList<Double> center;
double sumDistance;
double avgDistance;
int meassureType;
}