codecamp

Groovy 字符串长度

语法 - 由字符串的length()方法确定的字符串的长度。

参数 - 无参数。

返回值 - 显示字符串长度的整数。

例子

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

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

当我们运行上面的程序,我们将得到以下结果 -

5
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定