所以,我使用IntelliJ IDEA在Java中编程,我正在尝试使用关键字instanceof,我的代码看起来最终是这样的:
public class Main {
public static void main(String args[])
{
One one = new One();
One two = new Two();
if (one instanceof Two)
{
System.out.println(one);
}
if (two instanceof Two)
{
System.out.println(one);
}
}
}
class One { }
class Two extends One { }
Run Code Online (Sandbox Code Playgroud)
IntelliJ在线上给了我two instanceof Two一个提示"[...]总是真的",但是对于one instanceof TwoIntelliJ并没有给我一个"[...]总是假的"提示.有谁知道为什么?