concept length() in category java

appears as: length()
OCA Java SE 8 Programmer I Certification Guide

This is an excerpt from Manning's book OCA Java SE 8 Programmer I Certification Guide.

You can use the length() method to retrieve the length of a String. Here’s an example showing its use:

As mentioned in the earlier section on the String class, a String uses the method length() to retrieve its length. With an array, you can use the array’s variable length to determine the number of the array’s elements. In the exam, you may be tricked by code that tries to access the length of a String using the variable length. Note the correct combination of class and member used to access its length:

  • String—Retrieve length using the method length()