Goo*_*HTS 4 java reflection
假设我有一个名为"myfield"的字符串字段的类,并使用反射来获取字段,我发现它Object.getClass().getDeclaredField("myfield");区分大小写,NoSuchFieldException如果我使用它会抛出一个Object.getClass().getDeclaredField("MyField");
Object.getClass().getDeclaredField("myfield");
NoSuchFieldException
Object.getClass().getDeclaredField("MyField");
它有什么办法吗?强迫它忽略案例?
谢谢
Jon*_*eet 15
只需使用Class.getDeclaredFields()并查看结果,自己执行不区分大小写的匹配.
Class.getDeclaredFields()
归档时间:
15 年,5 月 前
查看次数:
8519 次
最近记录:
7 年,12 月 前