cara mencetak kalimat dalam serangkaian java case unta
boolean shouldConvertNextCharToLower = true;
Purple Team
boolean shouldConvertNextCharToLower = true;
for (int i = 0; i < text.length(); i++) {
char currentChar = text.charAt(i);
if (currentChar == delimiter) {
shouldConvertNextCharToLower = false;
} else if (shouldConvertNextCharToLower) {
builder.append(Character.toLowerCase(currentChar));
} else {
builder.append(Character.toUpperCase(currentChar));
shouldConvertNextCharToLower = true;
}
}
return builder.toString();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < words.length; i++) {
String word = words[i];
if (i == 0) {
word = word.isEmpty() ? word : word.toLowerCase();
} else {
word = word.isEmpty() ? word : Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase();
}
builder.append(word);
}
return builder.toString();
boolean shouldConvertNextCharToLower = true;
String[] words = text.split("[\\W_]+");