Skip to content

Latest commit

 

History

History
15 lines (11 loc) · 374 Bytes

File metadata and controls

15 lines (11 loc) · 374 Bytes

Length

The number of chars which comprise a String can be accessed by using .length().1

String fruit = "strawberry";
int numberOfChars = fruit.length();

// strawberry is 10 characters long
System.out.println(
    fruit + " is " numberOfChars + " characters long"
);

Footnotes

  1. This is different from the number of unicode codepoints.