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.
public static char toUpperCase(char ch)
char ch
- the character to convert to uppercaseThis method returns the uppercase version of the input character.
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
CONTRIBUTOR
View all Courses