Declared fields

Report a typo

Implement getNumberOfFieldsClassDeclares method to count the number of fields declared in a class. You should count public, protected, default (package) access, and private fields, excluding inherited fields.

Write a program in Java 17
/**
Get number of fields class declares (the ones inherited should be excluded).
*/
class FieldGetter {

public int getNumberOfFieldsClassDeclares(Class<?> clazz) {
// Add implementation here
}

}
___

Create a free account to access the full topic