Читать книгу OCP Oracle Certified Professional Java SE 17 Developer Study Guide - Jeanne Boyarsky - Страница 180
Limitations of Subtype Enforcement
ОглавлениеThe compiler has some limitations on enforcing pattern matching types when we mix classes and interfaces, which will make more sense after you read Chapter 7, “Beyond Classes.” For example, given the non-final
class Number
and interface List
, this does compile even though they are unrelated:
Number value = 123; if(value instanceof List) {} if(value instanceof List data) {}