0

Why when using instanceof in java to a null variable the output would be flase

3rd Dec 2018, 5:41 PM
Ishaq Za'rour
2 Answers
+ 2
instanceof will return true if the value/value of a variable being tested is of the type being compared to keep in mind that you never test variable but actually value inside a variable consider the following: boolean a = "Coder" instanceof String;//returns true boolean b = null instanceof String;)//returns false
4th Dec 2018, 12:38 AM
Rishi Anand
Rishi Anand - avatar
0
Thank you This helped alot
4th Dec 2018, 1:49 PM
Ishaq Za'rour