Groovy - 字符串长度



语法 − 字符串的长度由字符串的 length() 方法决定。

参数 − 无参数。

返回值 − 以整数形式显示字符串的长度。

示例

以下是在 Groovy 中使用字符串的示例 −

class Example {
   static void main(String[] args) {
      String a = "Hello";
      println(a.length());
   } 
}

运行以上程序后,会得到以下结果 −

5
groovy_strings.htm
广告
© . All rights reserved.