SeanChang 最近的时间轴更新
SeanChang

SeanChang

傻乎乎的程序员。
🏢  https://xuanyuan.me/blog
V2EX 第 7483 号会员,加入于 2011-03-30 20:47:30 +08:00
27 S 97 B
轩源
SeanChang 最近回复了
红米 note 系列,每两年换最新款。
118 天前
回复了 zhuzhifen 创建的主题 分享创造 随便整了个网站玩
海外工具站也是重运营。


https://xuanyuan.me/blog/
2022-11-15 15:09:29 +08:00
回复了 jawe001 创建的主题 Java 求 Java 大佬帮忙分析下这个程序
The incomparable types error is telling you that it doesn't make sense to compare two things that cannot possibly be equal.

For example, there's no point in Integer.valueOf(0) == "", because they're not the same types; nor is one a supertype of the other. It will always be false.

The compiler will prevent the a == b if both are class types (as opposed to interfaces), and both a = b and b = a would be disallowed.

So, you are being told that a Class<? extends T[]> cannot be equal to a Class<Object[]>, because you can't assign a reference of one type to a variable of the other type.

By casting one of the references to Object, the compiler no longer knows (/thinks) that the types are definitely not related - because Object is a supertype of everything, so "nor is one a supertype of the other" is no longer true - so the compiler allows the check.

One thing that is redundant in that method is U. There's no need for it, just use Object[] in the parameter type instead.
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   977 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms · UTC 20:27 · PVG 04:27 · LAX 13:27 · JFK 16:27
Developed with CodeLauncher
♥ Do have faith in what you're doing.