Java有没有C#那样可以对某个类进行扩展,添加新的方法
大家讲道理
大家讲道理 2017-04-18 09:15:39
0
5
397

例如帮String类型扩展一个ToInt()方法

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(5)
洪涛

String class is special... Others can be inherited and then added methods

大家讲道理

No. Java的类是死的, 一但写好就不再有更改能力. 你应该不是问, 通过继承来添加新的方法. 如果有的话, Scala也不用费劲搞个隐式视图To add methods to existing classes.

Well, this is not solid evidence either.

阿神

Are you talking about the interface?

刘奇

No. Scala and PHP have trait.

Java doesn’t even have the ability to alias classes.

阿神

Decorator mode.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template