Creating a new String with the Case Changed
String Methods
We've compiled some helpful String methods below.
![]() |
Methods that are part of the AP Computer Science A Java subset are denoted by the APCSA label. |
A complete list of String methods can be found in the String API.
String toLowerCase() & String toUpperCase()
String toLowerCase()
This method creates a new String where all uppercase letters of this String have been converted to lowercase letters.
String toUpperCase()
Similar to the method toLowerCase, but the method creates a new String where all lowercase letters of this String have been converted to uppercase letters.
Your Turn
Let's try it in the Java Playground.
- Predict the values of
lowerandupper. - Run the code to determine whether your prediction is correct.
lowerhas been assigned the valueduke loves java.upperhas been assigned the valueDUKE LOVES JAVA.
Complete List of String Learn Tutorials
- Learn: Declaring Strings
- Learn: Constructing a String
- Learn: String Indexing
- Learn: Comparing Strings with compareTo methods
- Learn: Comparing Strings with equals methods
- Learn: Creating Substrings
- Learn: Creaing a new String with the Case Changed
Resources
- Learn: Declaring Strings
- Learn: Introduction to Arithmetic Expressions
- Learn: Introduction to Console Input and Output
- Learn: Formatting Output with Escape Sequences and Text Blocks
- Practice: Evaluating Expressions that Use String Methods
- Practice: Write Code that Uses the String Methods
- Practice: AP Computer Science A String Free Response Questions
