Java Character toUpperCase(int codePoint) Method

Java toUpperCase(int codePoint) method is a part of Character class. This method converts the specified Unicode code point character argument to the uppercase using case mapping information which is provided by the Unicode Data file.

Syntax:

public static int toUpperCase(int codePoint) 

Parameters:

The parameter passed is the Unicode code point character value to be converted.

Returns:

Returns the uppercase equivalent of the specified character, if any; otherwise, the character itself.

Example 1:

Here, the specified characters are converted into its equivalent uppercase characters.

class StudyTonight
{  
	public static void main(String[] args)
	{  
		int cp1 = 78;  
		int cp2 = 102;  
		int cp3 = 66;  
		int cp4 = 48;   
		int cp5 = 123;  

		int ch1 = Character.toUpperCase(cp1);  
		int ch2 = Character.toUpperCase(cp2);  
		int ch3 = Character.toUpperCase(cp3);  
		int ch4 = Character.toUpperCase(cp4);  
		int ch5 = Character.toUpperCase(cp5);  

		System.out.println("The uppercase character code point is :"+ch1);  
		System.out.println("The uppercase character code point is :"+ch2); 
		System.out.println("The uppercase character code point is :"+ch3);  
		System.out.println("The uppercase character code point is :"+ch4);  
		System.out.println("The uppercase character code point is :"+ch5);  
	}  
}

The uppercase character code point is :78
The uppercase character code point is :70
The uppercase character code point is :66
The uppercase character code point is :48
The uppercase character code point is :123

Example 2:

Here is a user-defined example where anyone using this code can put a value of his choice and get the equivalent output.

import java.util.Scanner; 
public class StudyTonight
{  
	public static void main(String[] args)
	{  
		try
		{
			System.out.print("Enter the Unicode codepoint: ");  
			Scanner sc = new Scanner(System.in);         
			int cp = sc.nextInt();  
			int cc = Character.toUpperCase(cp);
			System.out.println("The uppercase character is : "+(char)cc);
		}
		catch(Exception e)
		{
			System.out.println("Invalid Input!!");
		}
	}  
}


Enter the Unicode codepoint: 101
The uppercase character is : E
*****************************************
Enter the Unicode codepoint: 113
The uppercase character is : Q

Live Example:

Here, you can test the live code example. You can execute the example for different values, even can edit and write your examples to test the Java code.