Here you can find the source of invertCase(String str)
public static String invertCase(String str)
//package com.java2s; //License from project: Open Source License public class Main { public static String invertCase(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return str; }//w w w. jav a 2 s . c om 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(); } }