Home > Java > Javagetting Started > body text

Which function in java can get the length of a string

王林
Release: 2020-06-22 13:20:53
Original
5779 people have browsed it

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();
Copy after login

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();
Copy after login

(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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template