package dfa; public class InstanceofPrimitivesNotAllowed { public static void main(String[] args) { testPrimitiveToPrimitive(); testPrimitiveToObject(); testObjectToPrimitive(); } private static void testObjectToPrimitive() { Integer i = 1; Object l = 1; if (i instanceof double) { } //error if (i instanceof int) { } //error if (i instanceof int ii) { } //error if (l instanceof double) { } //error if (l instanceof int) { } //error if (l instanceof int ii) { } //error } private static void testPrimitiveToPrimitive() { int i = 1; long l = 1; if (i instanceof double) { } //error if (i instanceof int) { } //error if (i instanceof int ii) { } //error if (l instanceof double) { } //error if (l instanceof int) { } //error if (l instanceof int ii) { } //error } private static void testPrimitiveToObject() { int i = 1; long l = 1; if (i instanceof Double) { } //error if (i instanceof Integer) { } //error if (i instanceof Object) { } //error if (i instanceof Integer ii) { } //error if (l instanceof Double) { } //error if (l instanceof Integer) { } //error if (l instanceof Object) { } //error } }