1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Java

Connected

Exercise

How long is a String?

Text comes in all sizes - from single characters to entire paragraphs. Knowing how many characters a String contains is essential for validation, formatting, and processing text. Let's discover how Java helps you measure Strings!

Instructions

100 XP
  • Use the .length() method to find out the length of the bookName variable, saving the result as bookNameLength.
  • Find the length of the author's name, "Terry Pratchett", and save it using the correct primitive type.