Android examples for java.lang:String Case
swap String Case
public class Main { /**// www . j a va2 s . c o m * * <pre> * StringUtil.swapCase(null) = null * StringUtil.swapCase("Han") = "hAN" * StringUtil.swapCase("hAn") = "HaN" * </pre> * */ public static String swapCase(String str) { if (str == null) { return null; } char[] charArray = str.toCharArray(); for (int i = 0; i < charArray.length; i++) { if (Character.isLowerCase(charArray[i])) { charArray[i] = Character.toUpperCase(charArray[i]); } else { charArray[i] = Character.toLowerCase(charArray[i]); } } return new String(charArray); } }