String Handling – toUpperCase( ) and toLowerCase ( )

toUpperCase( ) and toLowerCase ( )

Syntax

String toUpperCase ( );String toLowerCase ( );

toUpperCase() and toLowerCase() methods of String class is used to convert string of invoking object into upper case and lower case letters respectively and returns the resultant string.

class Example 1

{

public static void main ( String arg[ ])

{

String s1 = ”Code project”;

String s2=s1.toUpperCase( );

System.out.println(s1);

System.out.println(s2);

System.out.println(s1.toLowerCase());

}

}

output :-

Code project

CODE PROJECT

code project

Leave a Reply

Your email address will not be published. Required fields are marked *