donaricano-btn

 Instanceof

- instanceof operator is used to test whether the object is an instance of the specified type

- It is also known as type comparison operator

It returns either true or false


1. Example


- true

2. instanceof in java with a variable that have null value

 

- false

3. Downcasting with java instanceof operator

1) Downcasting

When subclass type refers to the object of Parent class, it is known as downcasting

 

 

2) Possibility of downcasting with instanceof

 

3) Downcasting without the use of instanceof

 

'Back-End > Java_1' 카테고리의 다른 글

[Java] Interface  (0) 2016.09.12
[Java] Abstract class  (0) 2016.09.12
[Java] Static Binding and Dynamic Binding  (0) 2016.09.08
[Java] Runtime Polymorphism  (0) 2016.09.08
[Java] Final keyword  (0) 2016.09.07
블로그 이미지

리딩리드

,