Why does `instanceof` error rather than return `false` when used for 2 incompatible classes?

前端 未结 4 1422
迷失自我
迷失自我 2020-12-11 17:58

I\'m reading this:
http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.20.2

They say:

Consider the example program

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 18:38

    Because the compiler knows that is impossible to an Element be a Point, so you get an compilation error.

提交回复
热议问题