1. tolowercase() method
This Java string method converts every character of the particular string into the lower case by using the rules of the default locale.
Note: This method is locale sensitive. Therefore it can show unexpected results if used for strings which are intended to be interpreted separately.
Syntax
public String toLowerCase()
Parameters
NA
Return Value
It returns the String, which is converted to lowercase.
Example 1:
public class Guru99 { public static void main(String args[]) { String S1 = new String("UPPERCASE CONVERTED TO LOWERCASE"); //Convert to LowerCase System.out.println(S1.toLowerCase()); } }
Output:
uppercase converted to lowercase
2. toUppercase () method
The toUppercase() method is used to convert all the characters in a given string to upper case.
Syntax:
toUpperCase()
Parameters:
NA
Returns value:
String in an uppercase letter.
Example 2:
public class Guru99 { public static void main(String args[]) { String S1 = new String("lowercase converted to uppercase"); //Convert to UpperCase System.out.println(S1.toUpperCase()); } }
Output:
LOWERCASE CONVERTED TO UPPERCASE
No comments:
Post a Comment