Java String case change

Introduction

Here are the simplest forms of these methods:

String toLowerCase()  
String toUpperCase() 

The default locale governs the conversion in both cases.


// Demonstrate toUpperCase() and toLowerCase().

public class Main {
  public static void main(String args[]) 
  {/*from   ww w .j av  a 2  s. c  o  m*/
    String s = "This is a test.";

    System.out.println("Original: " + s);

    String upper = s.toUpperCase();
    String lower = s.toLowerCase();

    System.out.println("Uppercase: " + upper);
    System.out.println("Lowercase: " + lower);
  }
}



PreviousNext

Related