Extend java.lang.String

前端 未结 5 929
甜味超标
甜味超标 2020-12-15 16:43

java.lang.String is declared as final, however are there any mechanisms available legitimate or otherwise to extend it and replace the equals(String other) method?

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 17:15

    You cannot extend a class that is marked as final. You can use composition to either put a String object inside or you can hand roll your own version. This can be accomplished via character arrays and the other magic that goes into creating String classes.

提交回复
热议问题