是否可以投射Map< Field,Value>到映射<镜像,镜像>当知道Field和Value扩展镜像? [英] Is it possible to cast Map<Field, Value> to Map<Mirror, Mirror> when it is known that Field and Value extend Mirror?
本文介绍了是否可以投射Map< Field,Value>到映射<镜像,镜像>当知道Field和Value扩展镜像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图向上投射地图< Field,Value>
到映射< Mirror,Mirror>
。
这对于转换是有意义的,因为 Field和Value extends Mirror
,但是我得到一个无法转换错误
是否不可能投放双重类型的地图
?
谢谢您,
p>
Dean
解决方案
我认为只有当您定义
地图< Field,Value&
为
地图< ;?扩展镜像,? extends Mirror>
但是否则就不一样了。
I am trying to cast upwards Map<Field, Value>
to Map<Mirror, Mirror>
.
It makes sense for the cast to work, as both Field and Value extend Mirror
, however I am getting a "cannot cast" error
.
Is it simply not possible to cast Maps with double types
? If so, how else can I cast?
I would appreciate any help!
Thank you,
Dean
解决方案
I think that would be possible only if you define the
Map<Field, Value>
as
Map<? extends Mirror, ? extends Mirror>
But otherwise, it's not the same thing.
这篇关于是否可以投射Map< Field,Value>到映射<镜像,镜像>当知道Field和Value扩展镜像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文