The method toLowerCase() converts all characters of a String to lower case. If no Locale is passed to the method, then it will use the default Locale.

However, it may produce unexpected results if it’s run on a system whose default Locale is different. To avoid this, we can simply pass the Locale to the method.

Available Signatures

public String toLowerCase(Locale locale)
public String toLowerCase()

Example

@Test
public void whenConvertToLowerCase_thenCorrect() {
    String s = "WELCOME to BAELDUNG!";
    
    assertEquals("welcome to baeldung!", s.toLowerCase());
}
Next »
Java String.toUpperCase()
« Previous
Java String.substring()
Course – LS – All

Get started with Spring and Spring Boot, through the Learn Spring course:

>> CHECK OUT THE COURSE
res – REST with Spring (eBook) (everywhere)
Comments are closed on this article!