How to Convert Java Characters From Lowercase to Uppercase
The Java programming language comes with many tools for handling text. One of the easiest ways to handle text in Java is to cast the text as a string and use Java's built-in functions for acting upon strings. Converting Java strings between upper- and lower-case characters using such functions is simple.
Instructions
-
Converting Characters to Uppercase
-
1
Cast the text in question as a string:
String basicText = "this text is all lowercase";
-
2
Call the function "toUpperCase" on the string:
String basicText = string.toUpperCase();
-
-
3
Output the text to verify it is all uppercase:
System.out.println(basicText);
Converting Characters to Lowercase
-
4
Cast the text in question as a string:
String basicText = "THIS STRING IS ALL UPPERCASE";
-
5
Call the function "toLowerCase" on the string:
String basicText = string.toLowerCase();
-
6
Output the text to verify it is all uppercase:
System.out.println(basicText);
-
1
References
Resources
- Photo Credit Thinkstock/Comstock/Getty Images