目录

int length()

描述 (Description)

此方法返回此字符串的长度。 长度等于字符串中的16位Unicode字符数。

语法 (Syntax)

以下是此方法的语法 -

public int length()

参数 (Parameters)

这是参数的细节 -

  • NA

返回值 (Return Value)

  • 此方法返回此对象表示的字符序列的长度。

例子 (Example)

import java.io.*;
public class Test {
   public static void main(String args[]) {
      String Str1 = new String("Welcome to iowiki.com");
      String Str2 = new String("Tutorials" );
      System.out.print("String Length :" );
      System.out.println(Str1.length());
      System.out.print("String Length :" );
      System.out.println(Str2.length());
   }
}

这将产生以下结果 -

输出 (Output)

String Length :29
String Length :9
↑回到顶部↑
WIKI教程 @2018