Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var totalDigits = 0;
var totalUppercaseChars = 0;
var totalLowercaseChars = 0;
var totalInvalidChars = 0;
for (final char current : string.toCharArray()) {
if (Character.isDigit(current)) {
totalDigits += 1;
} else if (Character.isUpperCase(current)) {
totalUppercaseChars += 1;
} else if (Character.isLowerCase(current)) {
totalLowercaseChars += 1;
} else {
totalInvalidChars += 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment