There is concept name open class in Ruby which could add new method to an existing class without writing a sub class.
There is also a technique classed implicit class in Scala which could do the same,here are some code snippet: with implicit class s, I actually add a new method isCorrect to the class String.
object ImplicitDemo {
implicit class s(s:String){
def isCorrect = s.startsWith("dw_")
}
def main(args: Array[String]) {
println("duowan" isCorrect )
}
}
So, is there a way I can do the same in pure java?