Overriding a method in an instantiated Java object

前端 未结 9 1435
陌清茗
陌清茗 2021-02-05 01:55

I would like to override a method in an object that\'s handed to me by a factory that I have little control over.

My specific problem is that I want to override the

9条回答
  •  一个人的身影
    2021-02-05 02:11

    You can't replace methods in existing objects - you can't change an existing object's type, for one thing.

    You could create a new instance of another class which delegated to the existing instance, but that has limitations too.

    In your real world case is there no way you can simply make a separate call to wrap the streams returned by the socket? Can you give more details.

提交回复
热议问题