Java toLowerCase toUpperCase

toLowerCase(): Converts all of the characters in this String to lower case.

Syntax:

public String toLowerCase()

toUpperCase(): Converts all of the characters in this String to upper case.

Syntax:

public String toUpperCase()

Example:

CaseChangeExample.java

/**
 * This program is used to show the use of 
 * toUpperCase and toLowerCase methods.
 * @author w3spoint
 */
class TestString{
	String str = "Jai";
 
	/**
	 * This method is used to show the use of toUpperCase() method.
	 * @author w3spoint
	 */
	public void upperCase(){
		//will convert all characters in upper case.
		System.out.println(str.toUpperCase());
	}
 
	/**
	 * This method is used to show the use of toLowerCase() method.
	 * @author w3spoint
	 */
	public void lowerCase(){
		//will convert all characters in lower case.
		System.out.println(str.toLowerCase());
	}
}
 
public class CaseChangeExample {
	public static void main(String args[]){
		//creating TestString object
		TestString obj = new TestString();
 
		//method call
		obj.upperCase();
		obj.lowerCase();
	}
}

Output:

JAI
jai

Download this example.
 
Next Topic: intern() String functions in java with example.
Previous Topic: indexOf(String str) and lastIndexOf(String str) String functions in java.

 

Content Protection by DMCA.com
Please Share