我最近继承的应用程序充满了关于构造函数的弃用警告:
Date d = new Date(int year, int month, int day)
有谁知道或可以指出为什么像这样简单的东西被这样的东西“取代”的原因:
Date d = null;
Calendar cal = GregorianCalendar.getInstance();
cal.set(1900 + year, month, day);
d = cal.getTime();
现在,显然弃用警告本身不是问题,但你能想象如果这个构造函数被删除,数百万的 LOC 会痛苦地哭泣吗?
在我简短的基准测试中,后者需要大约 50% 的时间来执行。