Let\'s say I have a class with a string field named \"myfield\", and use reflection to get the field, I\'ve found that Object.getClass().getDeclaredField(\"myfield\");
No, there is no direct way of doing this, however you could create a helper method for doing this. e.g. (untested)
public Field getDeclaredFieldIngoreCase( Class> clazz, String fieldName ) throws NoSuchFieldException {
for( Field field : clazz.getDeclaredFields() ) {
if ( field.getName().equalsIgnoreCase( fieldName ) ) {
return field;
}
}
throw new NoSuchFieldException( fieldName );
}