Here you can find the source of swapCasing(String str)
public static String swapCasing(String str)
//package com.java2s; public class Main { public static String swapCasing(String str) { int strLen; if ((str == null) || ((strLen = str.length()) == 0)) { return str; }/*from w w w . jav a2 s . co m*/ StringBuilder builder = new StringBuilder(strLen); char ch = 0; for (int i = 0; i < strLen; i++) { ch = str.charAt(i); if (Character.isUpperCase(ch)) { ch = Character.toLowerCase(ch); } else if (Character.isTitleCase(ch)) { ch = Character.toLowerCase(ch); } else if (Character.isLowerCase(ch)) { ch = Character.toUpperCase(ch); } builder.append(ch); } return builder.toString(); } }