本帖最后由 伍碧林 于 2011-10-12 22:45 编辑
xuan 发表于 2011-10-12 22:26
getInstance()方法返回的是Calendar类的实例吗
不会吧,抽象类怎么可以有实例呢 ...
文档是这样的."static Calendar getInstance() "
应该这样这么理解吧.返回的是以Calendar为父类的实例,也就是你说的子类实例
确实我的说法有问题;我还这样试了试
System.out.println(Calendar.getInstance());
结果:java.util.GregorianCalendar[time=1318430270484,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Shanghai",offset=28800000,dstSavings=0,useDaylight=false,transitions=19,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2011,MONTH=9,WEEK_OF_YEAR=42,WEEK_OF_MONTH=3,DAY_OF_MONTH=12,DAY_OF_YEAR=285,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=2,AM_PM=1,HOUR=10,HOUR_OF_DAY=22,MINUTE=37,SECOND=50,MILLISECOND=484,ZONE_OFFSET=28800000,DST_OFFSET=0]
|