I can not understand why you need this keyword. Explain by example, please.
Suppose I have a method in which you can pass an object of any type.
void foo(Object o){ //? } And I want to check what type the object belongs to. Probably, I did not correctly understand the essence of instanceof . But, nevertheless I will write as I consider
if(o instanceof Integer){ //Your logic } If you understand correctly, then explain whether it is possible to use the instanceof to switch/case ?
Also, if you understand correctly, please explain why it is needed, if you can create several methods for different logic?