+ 3
What is the use of instanceof keyword in java?
3 Respuestas
+ 4
Sort of.
It doesn't tell you what type the variable is, rather, it returns you a boolean determining whether or not what is being compared is of the type you specified.
Example/
Object a = "A string";
if(a instanceof String){
// true
}
+ 3
Now I understand, the name manifest itself "instance of" implies whether it is an intance(or object) of something or not.
like
ExampleClass s = new ExampleClass ();
boolean GotIt = s instanceof ExampleClass;
//true
+ 1
indicating as parameter a variable name, it tells you which type (or which object) is the variable in question...