Both code segments are used to determine if a number is even, but in the second example the code is moved to a method. This makes the code both more readable and allows us to reuse the code in the isEven() method
The isEven() method might be written something like this:
Although it takes more lines of code than the other option, it makes the main body of the code much easier to read. The more complex the if statement, the more likely a method returning a Boolean value would be a better alternative.
Use the word "is", "has" or "can" at the start of your method name to indicate that it returns a Boolean. This helps distinguish between a method that changes a value and one that checks if a value is true.
The method str.toUpperCase() converts a string to uppercase, while the method Character.isUpperCase(x) checks IF a character is uppercase or not, returning a Boolean