BlogsDope image BlogsDope

Java String toLowerCase()

March 5, 2021 STRING FUNCTION JAVA 137

The method toLowerCase() is used to convert all the characters of a String into lower-case characters. If you have a string with all upper-case characters or a mixture of upper-case and lower-case characters then this method converts the entire string into lower-case.

Java toLowerCase() Example

  • Input:"HeLLo"

       Output:"hello"

  • Input:"CODESDOPE"

       Output:codesdope

Java toLowerCase() Syntax

String.toLowerCase();

toLowerCase() Parameter

No parameters are used in this method.

toLowerCase() Return

This method returns a string in lowercase characters.

Program

package codesdope;
import java.util.*;
public class codesdope 
{
	public static void main(String[] args) 
	{
		String s1="WELCOme TO CODEsdoPE";
		String s2="HELLO WORLD";
		String s3="coding";
		System.out.println(s1.toLowerCase());    //case-1
		System.out.println(s2.toLowerCase());    //case-2
		System.out.println(s3.toLowerCase());    //case-3
	}
}

​welcome to codesdope 

hello world

coding

  • In the first case, when we have applied the toLowerCase() method on the string s1 i.e., "WELCOme TO CODEsdoPE" then this method converted all characters in the lower-case and returned the string in lower-case "welcome to codesdope".
  • In the second case, when we have applied the toLowerCase() method on the string s2 i.e "HELLO WORLD" then this method converted all characters in the lower-case and returned the string in lower-case "hello world".
  • In the third case, when we have applied the toLowerCase() method on the string s3 i.e "coding" then this method returned the same string because the string was already in the lower-case.

Liked the post?
Editor's Picks
0 COMMENT

Please login to view or add comment(s).