In this tutorial, I will show you how to use the instanceof operator. It tests whether an object is an instance of a class.
For example, if an object is not an instance of Student (either Student or Undergraduate or Graduate), it cannot be cast into a variable of Student. Using non-student object, getCode() would cause a compile error, because the Employee (or Faculty or Staff) class does not have the getCode method. The compiler cannot find a match for list.get(i).getCode. Therefore, it is necessary to cast list.get(i) into the Student type to tell the compiler that list.get(i) is also an instance of Student.
On this page of the site you can watch the video online Java Tutorial 70 - instanceof Operator with a duration of hours minute second in good quality, which was uploaded by the user Ken 24 April 2020, share the link with friends and acquaintances, this video has already been watched 156 times on youtube and it was liked by 3 viewers. Enjoy your viewing!