当前位置:
代码迷
>>
J2SE
>> numberformat是抽象类,为啥能被实例化
详细解决方案
numberformat是抽象类,为啥能被实例化
热度:
241
发布时间:
2016-04-23 22:53:34.0
numberformat是抽象类,为什么能被实例化
NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
我是新手,只知道抽象类不能被实例化,但这句话没错,是怎么回事。是因为返回的是子类吗?
------解决方案--------------------
亲,是接口不能被实例化。
当然,抽象类是不能直接被实例化的。
如果抽象类中没有抽象的方法,可以被实例化的。
相关解决方案
Java常用类库:NumberFormat
数字格式化类(NumberFormat、DecimalFormat)
NumberFormat 的用法