简体   繁体   English

无法在Eclipse中观看Java本地类实例

[英]unable to watch java local class instance in eclipse

Here is a small sample: 这是一个小样本:

public class LocalClassSample {
    public static void main(String[] args) {
        class Utils {
            public void printHello(String name) {
                System.out.println("Hello " + name);
            }
            public String outHello(String name) {
                return "hello " + name; 
            }
        }

        Utils util = new Utils();
        util.printHello("World");
    }
}

I put a break point at the last line. 我在最后一行放置了一个断点。 I am able to view util in the Variables window... 我可以在“变量”窗口中查看util ...

在此处输入图片说明

I try to view the same variable in the expressions window...it is unable to evaluate: 我尝试在表达式窗口中查看相同的变量...它无法求值:

在此处输入图片说明 Update: 更新:

Even tried inspecting the variable in the Display View...it does not evaluate: 即使尝试在“显示视图”中检查变量...也无法评估: 在此处输入图片说明

Expression eval a java expression like 'util.printHello("World")' and return the result ("Hello World"). 表达式评估一个Java表达式,例如'util.printHello(“ World”)'并返回结果(“ Hello World”)。 'util' is not an 'expression' but just a variable name, if you want to inspect it, use the Variables view or the Inspect command. “ util”不是一个“表达式”,而只是一个变量名,如果要检查它,请使用“变量”视图或“检查”命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM