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.
In questa pagina del sito puoi guardare il video online Java Tutorial 70 - instanceof Operator della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Ken 24 aprile 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 156 volte e gli è piaciuto 3 spettatori. Buona visione!