public class Test{
public static long getCamelCaseWordCountNormal(String in){
long words = in.isEmpty() ? 0 : 1;
for(char c : in.toCharArray()){
if(Character.isUpperCase(c)){
words++;
}
}
return words;
}
public static long getCamelCaseWordCountStreams(String in){
return in.isEmpty() ? 0 : 1 + in.chars().filter(Character::isUpperCase).count();
}
}
No comments:
Post a Comment