1. 学习
  2. /
  3. 课程
  4. /
  5. Introduction to Java

Connected

练习

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!

说明

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.