在Java中,给定一个对象,是否可以重写其中一种方法? [英] In Java, given an object, is it possible to override one of the methods?
本文介绍了在Java中,给定一个对象,是否可以重写其中一种方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个类A的对象。我想重写该类的方法之一。能做到吗?
I have an object of class A. I want to override one of the methods of that class. Can this be done?
更具体地说,我有一个被注入到字段中的对象。在使用它之前,我需要重写其中一种方法。
More specifically, I have an object that is being injected into a field. I need to override one of the methods, before I can use it.
我正在尝试查看反射是否可以帮助解决问题。请注意,我尝试覆盖的方法不依赖于该类的私有变量。
I am trying to see if Reflection could help solve the problem. Note that the method that I am trying override does not dependent on private variables of that class.
推荐答案
查看动态代理类。
这篇关于在Java中,给定一个对象,是否可以重写其中一种方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文