Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

java
uppercase
character
communitycreator

What is Character.toUpperCase() in Java?

abhilash

Overview

The toUpperCase() method is a static method in the Character class in Java that converts a character to uppercase.

The input for this function is a character.


If you need to convert a string to uppercase, refer to the String.toUpperCase method.

Syntax


public static char toUpperCase(char ch)

Parameters

  • char ch - the character to convert to uppercase

Return value

This method returns the uppercase version of the input character.

Code

In the code below, we use the toUpperCase function to convert different characters to uppercase.

public class Main {

    public static void main( String args[] ) {
        char ch = 'a';
        System.out.println(Character.toUpperCase(ch));

        ch = 'A';
        System.out.println(Character.toUpperCase(ch));

        ch = 'z';
        System.out.println(Character.toUpperCase(ch));
        
        ch = 'Z';
        System.out.println(Character.toUpperCase(ch));
    }
}

RELATED TAGS

java
uppercase
character
communitycreator
RELATED COURSES

View all Courses

Keep Exploring