Created
June 4, 2016 19:24
-
-
Save karl82/2e2013654946489b1e43e9cefe01d52c to your computer and use it in GitHub Desktop.
null instanceof Anything is always false
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.testng.annotations.Test; | |
import static org.hamcrest.CoreMatchers.instanceOf; | |
import static org.hamcrest.CoreMatchers.is; | |
import static org.hamcrest.CoreMatchers.not; | |
import static org.hamcrest.MatcherAssert.assertThat; | |
public class InstanceOfTest { | |
@Test | |
public void testNullInstanceOf() throws Exception { | |
assertThat(null, is(not(instanceOf(Object.class)))); | |
if (!(null instanceof Object)) { | |
System.out.println("null is never instanceof " + Object.class); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And the results is: