Answers for "check if field exists in java"

0

check if field exists in java

public boolean doesObjectContainField(Object object, String fieldName) {
    Class<?> objectClass = object.getClass();
    for (Field field : objectClass.getFields()) {
        if (field.getName().equals(fieldName)) {
            return true;
        }
    }
    return false;
}
Posted by: Guest on May-01-2021

Code answers related to "check if field exists in java"

Browse Popular Code Answers by Language