It is required to count the number of calls ( set and get ) to the private static field of the class MyClass .
Is the correct approach to addressing this issue applied below?
class MyClass { private static String str = "example string"; private static Integer countGetSet = 0; public static String getString() { countGetSet++; return str; } public static void setString(String inStr) { str = inStr; countGetSet++; } public static Integer getСountGetSet() { return countGetSet; } }