问题描述
共有两个类
foo.bar.FileUploader
和 barbar.foofoo .FileUploader
两者都是相同的,并扩展上传者
Both are identical and extend Uploader
在代码中,使用 foo.bar.FileUploader
,作为上传者
类型。
Somewhere in the code the foo.bar.FileUploader
is used and are given as a parameter to my function as an Uploader
type.
现在我需要将它转回 FileUploader
code> barbar.foofoo.FileUploader 。这会产生错误:
Now I need to cast it back to FileUploader
but the barbar.foofoo.FileUploader
. And this gives an error:
我不知道出了什么问题,我想这是因为包是不同的。在这种情况下:有没有办法仍然使用类并获得转换完成?
And I can't figure out what's going wrong, I suppose it's because the package is different. In that case: Is there a way to still use the class and get the cast done?
推荐答案
我刚刚通过导入barbar.foofoo.FileUploader来解决这个问题。现在它运行良好!
I just solved the problem by importing the the barbar.foofoo.FileUploader. Now it runs fine!
这篇关于如何转换类型的同一类,但从Java中的其他包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!