Home >Java >Javagetting Started >Which function in java can get the length of a string
The length() function in java can get the length of a string.
(Recommended tutorial: java introductory program)
The length() method in Java String is used to obtain the length of the string and use it as an int variable Returns the length of this string.
Syntax:
length();
Example:
Use the length() function to get the length of the string strCom2, and assign the returned result to the int type variable length.
String strCom2="php中文网"; int length=strCom2.length();
(Video tutorial recommendation: java video tutorial)
The above is the detailed content of Which function in java can get the length of a string. For more information, please follow other related articles on the PHP Chinese website!