Language
Version: SE 8
Categories
-
User Program Communication
-
Variables
-
Control Flow
-
Object Oriented Programming
-
String Class
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.");