Count public methods

Report a typo

Public methods of a class make up its public API, and it's crucial to know about them. Usually, a well-designed class doesn't have too many methods, otherwise, the class can be a god class. Of course, there are some exceptions, such as utility classes and some others.

To be aware of classes having too many methods, you need to implement a method that calculates how many public methods are declared in a given class.

Write a program in Java 17
class ReflectionUtils {

public static int countPublicMethods(Class targetClass) {
return 0;
}
}
___

Create a free account to access the full topic