fork download
  1. class Main {
  2. public static void main(String[] args) {
  3. solve("Teste");
  4. }
  5. public static void solve(String text) {
  6. int len = text.length();
  7. StringBuffer buffer = new StringBuffer(len);
  8. for (int i = 0; i < len; i++){
  9. char letter = text.charAt(i);
  10. buffer.append(i % 2 == 0 ? Character.toUpperCase(letter) : Character.toLowerCase(letter));
  11. }
  12. System.out.println(buffer);
  13. }
  14. }
  15.  
  16. //https://pt.stackoverflow.com/q/45347/101
Success #stdin #stdout 0.06s 32320KB
stdin
Standard input is empty
stdout
TeStE