Here you can find the source of swapCase(String str)
public static String swapCase(String str)
//package com.java2s; //License from project: Apache License public class Main { public static String swapCase(String str) { int strLen; if ((str == null) || ((strLen = str.length()) == 0)) { return str; }/*from w w w .ja va2 s. com*/ StringBuffer buffer = new StringBuffer(strLen); char ch = '\000'; 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); } buffer.append(ch); } return buffer.toString(); } }