- 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
Groovy - equals()
The method determines whether the Number object that invokes the method is equal to the object that is passed as argument.
Syntax
public boolean equals(Object o)
Parameters
o - Any object.
Return Value
The methods returns True if the argument is not null and is an object of the same type and with the same numeric value.
Example
Following is an example of the usage of this method −
class Example { static void main(String[] args) { Integer x = 5; Integer y = 10; Integer z = 5; //Comparison against an Integer of different value System.out.println(x.equals(y)); //Comparison against an Integer of same value System.out.println(x.equals(z)); } }
When we run the above program, we will get the following result −
false true
groovy_numbers.htm
Advertisements