AppDividend
Latest Code Tutorials

Java toLowerCase: How to Convert Lowercase Characters

The java string toLowerCase() method returns the string in the lowercase letter. In other words, it converts all characters of the string into a lower case letter.

Java String toLowerCase()

Java string toLowerCase() is a built-in function that converts any string to all lower characters. The string toLowerCase() method converts a string into all lowercase characters.

To convert a string to lower case in Java, use the string toLowerCase() method. The toLowerCase() method works same as toLowerCase(Locale.getDefault()) method. It internally uses the default locale.

Variants of Function

String toLowerCase():

The toLowerCase() method gets the current value of the default locale using the toLowerCase (Locale.getDefault()) method for the instance of the Java Virtual Machine.

This Java Virtual Machine sets the default locale during the start of the host environment. However, it can be changed using the setDefault() method.

Syntax

public String toLowerCase()

See the following program.

class LowerCase {
	public static void main(String args[]) {
		// initializing the string
		String s = "Welcome to APPDIVIDEND";
		// converting string s to lowercase letter
		String str = s.toLowerCase();
		System.out.println(str);
	}
}

See the output.Java String toLowerCase()

String toLowerCase(Locale locale)

The toLowerCase(Locale locale) method converts the string into LowerCase using the rules defined by some specified Locale.

Syntax

public String toLowerCase(Locale loc)

Here loc converts all characters into lowercase values using the rules defined in Locale.

See the following program.

import java.util.Locale;

class LowerCase {
	public static void main(String args[]) {
		// initializing the string
		String s = "Welcome to APPDIVIDEND.";
		// converting string s to lowercase letter using Locale method
		String eng = s.toLowerCase(Locale.ENGLISH);
		System.out.println(eng);
		String turkish = s.toLowerCase(Locale.forLanguageTag("tr")); // It shows i without dot
		System.out.println(turkish);
	}
}

See the output.

Convert String Characters To Lowercase

That’s it.

Recommended Posts

Java String toUpperCase()

Java String toCharArray()

Java String compareTo()

How to find string length In Java

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.