java.lang.Character toUpperCase(int codePoint)

Description

The Character.toUpperCase(int codePoint) java method converts the character (Unicode code point) argument to uppercase using case mapping information from the UnicodeData file.

Note that Character.isUpperCase(Character.toUpperCase(codePoint)) does not always return true for some ranges of characters, particularly those that are symbols or ideographs.

In general, String.toUpperCase() should be used to map characters to uppercase. String case mapping methods have several benefits over Character case mapping methods. String case mapping methods can perform locale-sensitive mappings, context-sensitive mappings, and 1:M character mappings, whereas the Character case mapping methods cannot.

The toUpperCase(char ch) method of Character class is static thus it should be accessed statically which means the we would be calling this method in this format:

Character.toUpperCase(int codePoint)

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java toUpperCase() method non statically.

Method Syntax

public static int toUpperCase(int codePoint)

Method Argument

Data Type Parameter Description
int codepoint the character (Unicode code point) to be converted.

Method Returns

The toUpperCase(int codePoint) method of Character class returns the uppercase equivalent of the character, if any; otherwise, the character itself.

Compatibility

Requires Java 1.5 and up

Java Character toUpperCase(int codePoint) Example

Below is a simple java example on the usage of toUpperCase(int codePoint) method of Character class.

package com.javatutorialhq.java.examples;

/*
 * This example source code demonstrates the use of 
 * toUpperCase(int codePoint) method of Character class.
 */

public class CharacterToUpperCaseCodePointExample {

	public static void main(String[] args) {

		// initialize a char
		int codepoint = 102;

		// convert codepoint to char
		char ch = (char) codepoint;	

		// convert the code point to upper case
		char chUpper = Character.toUpperCase(ch);
		// print the result
		System.out.println("character '" + ch + "' upper case is " + chUpper);
		

	}

}

Sample Output

Below is the sample output when you run the above example.

java Character toUpperCase(int codePoint) example output