java局部变量不可用 [英] java local variable unavailable

查看:72
本文介绍了java局部变量不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 Eclipse 调试器收到以下错误:局部变量不可用.试图尽可能地修剪代码.问题很简单,我必须使用来自 Divise 类的 DivisiveUI UpdateLog() 方法,使用来自 Cluster 类的变量.Divise 有一个包含所有集群的列表.Divisive 和 DivisiveUI 相互引用.如何从 Divisive 类访问变量:sumDistance、avgDistance?尝试在 Divisive 类中编写方法,仍然无法访问所需的变量:|谢谢!

I'm getting the following error from the eclipse debugger: local variable unavailable. Tried to trim the code as much as possible. The problem is pretty simple, I have to use the DivisiveUI UpdateLog() method, from the Divise class, using variables from the Cluster class. The Divise has a list containing all of the clusters. Divisive and DivisiveUI has a reference to each other. How can I get access to the variables: sumDistance, avgDistance from the Divisive class? Tried writing a method in the Divisive class, still couldn't access the needed variables :| Thank you!

log.append(text+"\n") 处的错误裁剪;未找到来源.

Error crops at log.append(text+"\n"); Source Not Found.

分裂:

   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);
        }

    }

分裂用户界面:

 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;
}

推荐答案

如果调试器无法访问局部变量,则表示代码尚未通过从字节码中添加局部变量调试信息的选项进行编译.

If the debugger can't acces the local variable, that means that the code hasn't been compiled with the option adding the local variable debugging information from the bytecode.

检查您是如何编译这些类的,并确保此信息位于已编译的类中.如果使用 javac,则添加 -g 选项以添加所有调试信息.

Check how you're compiling the classes, and make sure this information is in the compiled classes. If javac is used, add the -g option to ad all the debugging information.

这篇关于java局部变量不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆