Skip Top Navigation Bar

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 lower and upper.
  • Run the code to determine whether your prediction is correct.

  • lower has been assigned the value duke loves java.
  • upper has been assigned the value DUKE LOVES JAVA.

Complete List of String Learn Tutorials

Resources

Next Learn Tutorial