以下编译正常:
Object o = new Object();
System.out.println(o instanceof Cloneable);
Run Code Online (Sandbox Code Playgroud)
但这不是:
String s = new String();
System.out.println(s instanceof Cloneable);
Run Code Online (Sandbox Code Playgroud)
抛出编译器错误.
问题是什么?
我已经阅读了各种文章,但我仍然不知道为什么不应该使用instanceof.kindlylet我知道你的想法.