Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Groovy previous()

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

Groovy plus()

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

Groovy padRight()

class Example { 
   static void main(String[] args) { 
      String a = "Hello World"; 
		
      println(a.padRight(14)); 
      println(a.padRight(16)); 
      println(a.padRight(16,'*')); 
      println(a.padRight(14,'*')); 
   } 
}

Groovy padLeft()

class Example { 
   static void main(String[] args) { 
      String a = "Hello World";
		
      println(a.padLeft(14)); 
      println(a.padLeft(16)); 
      println(a.padLeft(16,'*')); 
      println(a.padLeft(14,'*')); 
   } 
}

Groovy next()

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

Groovy minus()

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

Groovy matches()

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

Groovy indexOf()

class Example { 
   static void main(String[] args) { 
      String a = "Hello World"; 
		
      // Using public int indexOf(int ch) 
      println(a.indexOf('e')); 
      println(a.indexOf('o')); 
		
      // Using public int indexOf(int ch, int fromIndex) 
      println(a.indexOf('l',1)); 
      println(a.indexOf('e',4));
		
      // Using public int indexOf(string str) 
      println(a.indexOf('el')); 
      println(a.indexOf('or')); 
		
      // Using public int indexOf(string str,int fromIndex) 
      println(a.indexOf('el',1)); 
      println(a.indexOf('or',8)); 
   } 
}

Groovy getAt()

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

Groovy equalsIgnoreCase()

class Example { 
   static void main(String[] args) { 
      String a = "Hello World"; 
      String b = "HELLO World"; 
      String c = "HELLO WORLD";
		
      println(a.equalsIgnoreCase(b)); 
      println(a.equalsIgnoreCase(c)); 
      println(b.equalsIgnoreCase(c)); 
   } 
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.