Groovy - minus()



Removes the value part of the String.

Syntax

String minus(Object value)

Parameters

Value – the string object which needs to be removed

Return Value

The new string minus the value of the object value.

Example

Following is an example of the usage of this method −

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

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

Hello  
World
groovy_strings.htm
Advertisements