使用Eclipse调查Java中的数据结构 [英] Investigate a data structure in Java with Eclipse

查看:358
本文介绍了使用Eclipse调查Java中的数据结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在java中有一个对象,我知道这个对象包含对我有用的信息,问题是我不知道这些字段的名称,我不知道这个对象是否包含真实数据或只是引用,考虑到这一点,事实上我只知道这个对象的标签,我有什么选择来调试这个数据结构并获取信息?



列出与特定类型相对应的每个对象?

解决方案

打印(和搜索)类中的字段:

  static Object fieldOdClass(final String className,
final String valeurRecherche1){
try {
final Field [ ] f = Class.forName(className).getFields(); (int i = f.length - 1; i> = 0; i--){
System.out.println(f [i] .toString());

if(f [i] .toString()。endsWith(valeurRecherche1)){
return f [i] .toString();
}
}
} catch(final ClassNotFoundException e){
//管理错误;
}
}


I have an object in java, I know that this object contains useful informations for me, the problem is I don't know the names of the fields, I don't know if this object contains real data or just references, considering this and the fact that I only know the label of this object, what options do I have to debug this data structure and get informations out of it?

It's possible to list every objects corresponding to a particular type?

解决方案

To print (and search) a field in a class :

static Object fieldOdClass(final String className,
        final String valeurRecherche1) {
        try {
            final Field[] f = Class.forName(className).getFields();
            for (int i = f.length - 1; i >= 0; i--) {
                System.out.println(f[i].toString());
                if (f[i].toString().endsWith(valeurRecherche1)) {
                    return f[i].toString();
                }
            }
        } catch (final ClassNotFoundException e) {
            // manage errors;
        }
    }

这篇关于使用Eclipse调查Java中的数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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