eval()函数解析器和二维数组在Java中的FPGA实现 [英] ImplementIon of eval() parser and 2d array in Java

查看:215
本文介绍了eval()函数解析器和二维数组在Java中的FPGA实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的卡在两个Java相关的问题。一个简单的和一个较困难。

I have really stuck on two Java related issues. One simple and one more difficult.

对于建立一个二维数组,我初始化这样的一个表:

Regarding the creation of a 2D array, I initialize a table like this:

private String [][] table_of_classifiers = null;

然后,在一个函数中,我填写的内容是这样的:

and then, within a function, I fill its contents like this:

        String [][] table_of_classifiers = {
            {"x1","x","x","x","x"},
            {"x2","x","x","x","x"},
            {"x3","x","x","x","x"},
            {"x4","x","x","x","x"},
            {"x5","x","x","x","x"},
            {"x6","x","x","x","x"},
        };

但你能猜到第二个表覆盖(本地)第一个,那当然不是我想做的事情。我做错了什么?注意,表的尺寸不从一开始就知道

But as you can guess the second table overwrites (locally) the first one, that is of course not what I want to do. What I do wrong? Note that the dimension of the table is not known from the beginning.

推荐答案

只要做到:

class Foo {
    private String [][] table_of_classifiers = null;

    void bar() {
        table_of_classifiers = new String[][] {
                    {"x1","x","x","x","x"},
                    {"x2","x","x","x","x"},
                    {"x3","x","x","x","x"},
                    {"x4","x","x","x","x"},
                    {"x5","x","x","x","x"},
                    {"x6","x","x","x","x"},
        };
    }
}

Java没有评估(因为它是一个编译型语言),但它确实具有的 反射。这几乎可以肯定不是最好的方法不管它是什么,你想做的事,但。

Java doesn't have eval (because it's a compiled language), but it does have reflection. It's almost certainly not the best approach to whatever it is that you want to do, though.

这篇关于eval()函数解析器和二维数组在Java中的FPGA实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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