
- Groovy Tutorial
- Groovy - Home
- Groovy - Overview
- Groovy - Environment
- Groovy - Basic Syntax
- Groovy - Data Types
- Groovy - Variables
- Groovy - Operators
- Groovy - Loops
- Groovy - Decision Making
- Groovy - Methods
- Groovy - File I/O
- Groovy - Optionals
- Groovy - Numbers
- Groovy - Strings
- Groovy - Ranges
- Groovy - Lists
- Groovy - Maps
- Groovy - Dates & Times
- Groovy - Regular Expressions
- Groovy - Exception Handling
- Groovy - Object Oriented
- Groovy - Generics
- Groovy - Traits
- Groovy - Closures
- Groovy - Annotations
- Groovy - XML
- Groovy - JMX
- Groovy - JSON
- Groovy - DSLS
- Groovy - Database
- Groovy - Builders
- Groovy - Command Line
- Groovy - Unit Testing
- Groovy - Template Engines
- Groovy - Meta Object Programming
- Groovy Useful Resources
- Groovy - Quick Guide
- Groovy - Useful Resources
- Groovy - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Groovy - compareToIgnoreCase()
Compares two strings lexicographically, ignoring case differences.
Syntax
int compareToIgnoreCase(String str)
Parameters
Str – String value for comparison.
Return Value
This method returns a negative integer, zero, or a positive integer as the specified String is greater than, equal to, or less than this String, ignoring case considerations.
Example
Following is an example of the usage of this method −
class Example { static void main(String[] args) { String str1 = "Hello World"; String str2 = "HELLO WORLD"; String str3 = "HELLO World World"; System.out.println(str1.compareToIgnoreCase( str2 )); System.out.println(str2.compareToIgnoreCase( str3 )); System.out.println(str3.compareToIgnoreCase( str1 )); } }
When we run the above program, we will get the following result −
0 -6 6
groovy_strings.htm
Advertisements