There will be times when we have a word in a case other than what we need it in. Luckily, Java has a couple String methods to help us out:

  • toUpperCase(): returns the string value converted to uppercase
  • toLowerCase(): returns the string value converted to lowercase

For example:

String input = "Cricket!"; String upper = input.toUpperCase(); // stores "CRICKET!" String lower = input.toLowerCase(); // stores "cricket!"

A good use of this functionality is to ensure consistency of the data you store in a database. Making sure all of the data you get from a user is lowercase before you store it in your database will make your database easier to search through later.



In Hashtag.java, use toLowerCase() to print out the lower case version of hashtag.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?