Suppose, we have a utility method to capitalize strings:
class Util {
public static String capitalize(String str) {
if (str == null || str.isBlank()) {
return str;
}
if (str.length() == 1) {
return str.toUpperCase();
}
return Character.toUpperCase(str.charAt(0)) + str.substring(1);
}
}
Your task is to add some logging to this method so it prints the input string and the string to be returned by the method in the following format:
Before: string
After: String
where string is an example of the input string. As you can see, the method has three execution paths and they all must be logged.