Java Number Swap swapCasing(String str)

Here you can find the source of swapCasing(String str)

Description

swap Casing

License

Open Source License

Declaration

public static String swapCasing(String str) 

Method Source Code

//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();
    }
}

Related

  1. swapAddresses(T o1, T o2)
  2. swapBits(byte in)
  3. swapBits(int b, int i, int j)
  4. swapByte(byte b)
  5. swapBytes(final int i)
  6. swapDouble(double value)
  7. swapDouble(double value)
  8. swapFloat(float floatValue)
  9. swapFloat(float value)