使用Eclipse调查Java中的数据结构 [英] Investigate a data structure in Java with Eclipse
本文介绍了使用Eclipse调查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屋!
查看全文