Ad
Code
Diff
  • class HeLlOwOrLddddd {
    
      static String convert(String s) {
        boolean[] f = {false};
        return s.chars()
            .filter(Character::isLetter)
            .map(cp -> (f[0] = !f[0]) ? Character.toUpperCase(cp) : Character.toLowerCase(cp))
            .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
            .toString();
      }
    
    }
    
    • public class HeLlOwOrLddddd {
    • public static String convert(String s) {
    • StringBuilder sb = new StringBuilder();
    • boolean f = false;
    • for (char x : s.toCharArray())
    • if (Character.isLetter(x))
    • sb.append((f = !f) ? Character.toUpperCase(x) : Character.toLowerCase(x));
    • return sb.toString();
    • class HeLlOwOrLddddd {
    • static String convert(String s) {
    • boolean[] f = {false};
    • return s.chars()
    • .filter(Character::isLetter)
    • .map(cp -> (f[0] = !f[0]) ? Character.toUpperCase(cp) : Character.toLowerCase(cp))
    • .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
    • .toString();
    • }
    • }
    • }