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();
      }
    
    }
    
  • 1
    public class HeLlOwOrLddddd {
    
    2
      public static String convert(String s) {
    
    3
        StringBuilder sb = new StringBuilder();
    
    4
        boolean f = false;
    
    5
        for (char x : s.toCharArray())
    
    6
          if (Character.isLetter(x))
    
    7
            sb.append((f = !f) ? Character.toUpperCase(x) : Character.toLowerCase(x));
    
    8
        return sb.toString();
    
    1+
    class HeLlOwOrLddddd {
    
    2+
    3+
      static String convert(String s) {
    
    4+
        boolean[] f = {false};
    
    5+
        return s.chars()
    
    6+
            .filter(Character::isLetter)
    
    7+
            .map(cp -> (f[0] = !f[0]) ? Character.toUpperCase(cp) : Character.toLowerCase(cp))
    
    8+
            .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
    
    9+
            .toString();
    
    99
      }
    
    11+
    1010
    }