Boolean-Valued Methods
In this lesson, we will explore some examples of methods that return either true or false.
We'll cover the following...
The chapter Using Classes and Objects introduced methods that compare two objects and return a value based on the result of the comparison. In particular, we described the method equals
for the class String
. This method tests whether two strings are the same by returning either true or false. Further, we gave an example of using an if
statement to react to the result of String
’s equals
method. Classes often include methods like equals
that return a Boolean value.
A Class of calendar dates
Imagine a ...
Access this course and 1400+ top-rated courses and projects.