Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

ToLowerCase and toUpperCase

public class MainClass {    public static void main( String args[] )    {       String s1 = new String( "hello" );       String s2 = new String( "GOODBYE" );       String s3 = new String( "   spaces   " );       System.out.printf( "s1 = %s\ns2 = %s\ns3 = %s\n\n", s1, s2, s3 );       // test toLowerCase and toUpperCase       System.out.printf( "s1.toUpperCase() = %s\n", s1.toUpperCase() );       System.out.printf( "s2.toLowerCase() = %s\n\n", s2.toLowerCase() );    } } s1 = hello s2 = GOODBYE s3 = spaces s1.toUpperCase() = HELLO s2.toLowerCase() = goodbye