Calendar.before(Object when),为什么Object? [英] Calendar.before(Object when), why Object?
问题描述
从 Calendar.before(Object when)
的javadoc:
返回此日历是否表示时间之前由指定的对象表示的时间。此方法等效于:
Returns whether this Calendar represents a time before the time represented by the specified Object. This method is equivalent to:
compareTo(when) < 0
当且仅当when是一个日历实例。
if and only if when is a Calendar instance. Otherwise, the method returns false.
为什么接受一个对象,如果当某人传递的东西不是一个日历实例,它返回false?为什么不只是接受一个日历实例?
Why does it accepts an Object if when someone passes something that's not a Calendar instance it returns false? Why not just accepting a Calendar instance? This kept me watching for uncorrect results in a functionality for quite some time.
推荐答案
我认为没有什么特别的原因。 java.util.Calendar
有一些我们不得不生活的设计问题。不幸的是。
I think there is no particular reason for that. java.util.Calendar
has some design issues we have have to live with, unfortunately.
这篇关于Calendar.before(Object when),为什么Object?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!