Skip to content
Advertisement

How to count count the number of names Java

Hi guys. I’m new to Java, currently learning Strings.

I have a task to count the number of names, the length of the name must be at least two, the first letter of the name should start with upper case, the second with lower case.

The issue is that I don’t know how to use the Character.isUpperCase(text.charAt(i)) and Character.isLowerCase(text.charAt(i + 1)) in the same if.

I would use some advice or hint.

JavaScript

Advertisement

Answer

You can use word.charAt(0) and word.charAt(1) to get the first and second character in each word in the loop.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement