我有一个类,但是该类里面有一个接口的属性,现在是想通过反射获取一个实现该接口的实例,即获取一个a,并且这个a的body已经是我指定的接口实现类的,请问怎么实现?
class a{
Body body;
}
interface Body{
}
class BodyImpl{
//do something
}
è°¢è°¢ä½ çåçï¼ä¸è¿ä½ 误解æææäºï¼ææ¯æ³éè¿Class aè·åä¸ä¸ªç±å®èªèº«bodyå±æ§å®ç°bodyæ¥å£çå®ä¾ï¼ä¸æ¯æ³å¾bodyçæ¥å£
Java反射-属性操作