I think it will print Nothing.Because Calender.MONTH value is 2 always and not equal to Calender.OCTOBER which is 9,So the method isHalloween(Calendar cal) will always return false ,So the result.
If I am wrong suggest me.
Joined: Aug 25, 2006
indeed you're wrong the line of code was: if (cal.get(Calendar.MONTH) != Calendar.OCTOBER) and the method called, get has the signature
int java.util.Calendar( int field)
and if you don't want to look up in the Calendar API what integer now actually stands for the field "month", use a constant instead. The method does not return the number of the constant, but what is written in the field "month".
And I compared it also not with an integer (would be nine for october, as the months start with zero. Also the Maya used zero based dates by the way).
And as I don't want to confuse somebody, I'd rather use the constant Calendar.OCTOBER than the integer 9 directly. Sooner or later somebody will think, Halloween is in September then.
To all the others: At least nobody stepped into the trap:"Hey! He's instantianting Throwable! Just by the name ending in "-able" you can guess it is an interface!"
Output yesterday: Trick today, no output.
class Throwable is Serializable. So you can serialize a RuntimeException, store it to disk and send it by mail to everyone who doesn't have one. ;-)