Groovy - getAt()



Syntax

String getAt(int index)

Parameters

  • Index – The position of the string to return

Return Value

String value at the index position

Example

Following is an example of the usage of this method −

class Example { 
   static void main(String[] args) { 
      String a = "Hello World"; 
		
      println(a.getAt(2)); 
      println(a.getAt(6)); 
      println(a.getAt(7)); 
   } 
}

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

l 
W 
O
groovy_strings.htm
Advertisements