Home »
Java programming language
Java Character class toUpperCase() method with example
Character class toUpperCase() method: Here, we are going to learn about the toUpperCase() method of Character class with its syntax and example.
Submitted by Preeti Jain, on October 26, 2019
Character class toUpperCase() method
- toUpperCase() method is available in java.lang package.
- toUpperCase() method is used to return the uppercase character of the given char value.
- toUpperCase() method does not throw an exception at the time of representing lowercase character to uppercase character or uppercase to the uppercase character.
Syntax:
public char toUpperCase (Char value);
Parameter(s):
- Char value – represents the char value to be converted.
Return value:
The return type of this method is char, it returns the uppercase conversion of the given char value.
Example:
// Java program to demonstrate the example
// of char toUpperCase (Char value) method of Character class
public class ToUpperCaseOfCharacterClass {
public static void main(String[] args) {
// It returns P because the passing character is
// already in UpperCase
char result1 = Character.toUpperCase('P');
// It returns P because the passing character will
// be converted to UpperCase by using toUpperCase()
char result2 = Character.toUpperCase('p');
// Display values of result1 , result2
System.out.println("Character.toUpperCase('P'): " + result1);
System.out.println("Character.toUpperCase('p'): " + result2);
}
}
Output
Character.toUpperCase('P'): P
Character.toUpperCase('p'): P
TOP Interview Coding Problems/Challenges