Java - Character Class toUpperCase() Method

Character class toUpperCase() method: Here, we are going to learn about the toUpperCase() method of Character class with its syntax and example. By Preeti Jain Last updated : March 17, 2024

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);

Parameters

  • 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

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.