tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Commons Lang3 > Strings > Swapcase

Swapcase 

Apache Commons Lang 3.0 is a java library with lot of utilities and reusable components. This requires the library commons-lang3-3.0.1.jar to be in classpath. The following example shows using StringUtils.swapCase() API. It swaps the case of all characters in the given string from upper case to lower case and lower case to upper case.

File Name  :  
com/bethecoder/tutorials/commons_lang/tests/strings/SwapCaseTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.commons_lang.tests.strings;

import org.apache.commons.lang3.StringUtils;

public class SwapCaseTest {

  /**
   @param args
   */
  public static void main(String[] args) {
         
    System.out.println(StringUtils.swapCase(null));
    System.out.println(StringUtils.swapCase(""));
    System.out.println(StringUtils.swapCase("name"));
    System.out.println(StringUtils.swapCase("AGE"));
    System.out.println(StringUtils.swapCase("Be The Coder"));
  }

}
   

It gives the following output,
null

NAME
age
bE tHE cODER



 
  


  
bl  br