List public fields

Report a typo

Implement the getPublicFields method that returns String array with names of public fields declared in the class object belongs to. Fields inherited from parent classes should be omitted.

Write a program in Java 17
/**
Get list of public fields the object declares (inherited fields should be skipped).
*/
class FieldGetter {

public String[] getPublicFields(Object object) {
// Add implementation here
}

}
___

Create a free account to access the full topic