Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 394 Bytes

length.md

File metadata and controls

17 lines (13 loc) · 394 Bytes

Length

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

~void main() {
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.