What you learn on paper is shallow, but you know you have to do it in detail
--Lu You Ask the canal how clear it is to have a source of living water --Zhu Xi
instanceof is actually a binary operator in Java, used to determine the object## on the left #Whether it is an instance of the specific class on the right or its subclass, return boolean type data. Generally, when using non-generic collections (List, set, etc.), instanceof is often used. Since collections can store various objects, they generally need to be read when reading. corresponding judgment.
A { }
B A{ }
Hello { (String[] args) { A a=A()B b=B()A aa=(a A) { System..println()}{ System..println()} (b A){ System..println()} else{ System..println()} (aa A) { System..println()}{ System..println()} } }
true true false
The above is the detailed content of Java-instanceof summary code example. For more information, please follow other related articles on the PHP Chinese website!