Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #field #exists #java
ADD COMMENT
Topic
Name
1+6 =