Groovy - String Length


Advertisements

Syntax − The length of the string determined by the length() method of the string.

Parameters − No parameters.

Return Value − An Integer showing the length of the string.

Example

Following is an example of the usage of strings in Groovy −

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

When we run the above program, we will get the following result −

5
groovy_strings.htm
Advertisements