Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
null instanceof Anything is always false
import org.testng.annotations.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
import static;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
public class InstanceOfTest {
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);

This comment has been minimized.

Copy link
Owner Author

@karl82 karl82 commented Jun 4, 2016

And the results is:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.