equals(Object): This method is available in java.util.Date class of Java.
Syntax:
boolean java.util.Date.equals(Object obj)
This method takes one argument of type Object (like Date) as its parameter. This method compares two dates for equality.
Note: The result is true if and only if the argument is not null and is a Date object that represents the same point in time, to the millisecond, as this object.
Parameters: One parameter is required for this method.
obj: the object to compare with.
Returns: true if the objects are the same; false otherwise.
Exceptions: NA
Approach
Java
import java.util.Date;public class Dateequals {public static void main(String[] args) {Date date = new Date();Object obj = new Date();System.out.println(date.equals(obj));}}
Output:
true
No comments:
Post a Comment