問題描述
來自Calendar.before(Object when)
的javadoc:
From the javadoc of Calendar.before(Object when)
:
返回此日歷是否表示指定對象表示的時間之前的時間.該方法等價于:
Returns whether this Calendar represents a time before the time represented by the specified Object. This method is equivalent to:
compareTo(when) < 0
當且僅當 when 是 Calendar 實例.否則,該方法返回 false.
if and only if when is a Calendar instance. Otherwise, the method returns false.
如果當有人傳遞不是 Calendar 實例的東西時它返回 false,為什么它會接受 Object?為什么不直接接受 Calendar 實例?這讓我在很長一段時間內一直在關注某個功能中的不正確結果.
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?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!