Java program to compare time using equals() method
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
In this program, we will create objects of the LocalTime class with the specified time. Then we will compare two times using the equals() method and print appropriate messages.
Program/Source Code:
The source code to compare time using the equals() method is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we imported the "java.util.*" package to use the Date class. Here, we created a class Main that contains a static method main(). The main() method is the entry point for the program, here we created three objects of the LocalTime class with the specified time. Then we compared created objects using the equals() method and printed appropriate messages.