Implement the getNumberOfAccessibleFields method to count the number of accessible public fields of the class or interface represented by the clazz object.
Reflection basics
Field count
Report a typo
Write a program in Java 17
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
/**
Get number of accessible public fields for a given class.
*/
class FieldGetter {
public int getNumberOfAccessibleFields(Class<?> clazz) {
// Add implementation here
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.