String Class

String Length in Java

String length returns the number of characters in a string.


Syntax
int length = stringName.length();

Notes

Spaces count as characters.


Example
String name = "Anthony";
int nameLength = name.length();
System.out.println("The name " + name + " contains " + nameLength + "letters.");

See Also
Documentation

String Class - Java Docs

Add to Slack

< String Variables   |   String Compare >

© 2019 SyntaxDB. All Rights Reserved.