Java: String toLowerCase() method

In this article, we will discuss how to convert each individual characters inside a String into a lowercase character using String’s toLowerCase() method

toLowerCase () method: This String method is used to convert invoking sequence/string into lowercase characters (all character present in string/sequence)

 

Method Signature:

public String toLowerCase();

 

Returns:

  • String converted to lowercase

 

Examples on toLowerCase() method:

To convert all characters present in the invoking string into lowercase

StringToLowerCaseMethod.java

package in.bench.resources.string.methods;

public class StringToLowerCaseMethod {

	public static void main(String[] args) {

		// sample string
		String url = "BenchResources.Net";

		// convert all characters present inside string into lower-case
		String lowerCase = url.toLowerCase();

		// print to console - converted lower-case string
		System.out.println("Converted lower-case is : " + lowerCase);
	}
}

Output:

Converted lower-case is : benchresources.net

 

Hope, you found this article very helpful. If you have any suggestions or want to contribute any other way or tricky situation you faced during Interview hours, then share with us. We will include that code here.

 

References:

https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html
https://docs.oracle.com/javase/tutorial/essential/concurrency/imstrat.html
https://docs.oracle.com/javase/tutorial/java/data/strings.html
https://docs.oracle.com/javase/6/docs/api/java/lang/String.html
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html
https://docs.oracle.com/javase/6/docs/api/java/lang/class-use/String.html
https://docs.oracle.com/javase/7/docs/api/java/lang/class-use/String.html
https://docs.oracle.com/javase/8/docs/api/java/lang/class-use/String.html
https://docs.oracle.com/javase/6/docs/api/java/lang/StringBuffer.html
https://docs.oracle.com/javase/7/docs/api/java/lang/StringBuffer.html
https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html
https://docs.oracle.com/javase/6/docs/api/java/lang/StringBuilder.html
https://docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html
https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html

 

Happy Coding !!
Happy Learning !!

Java: String toString() method
Java: String toCharArray() method