java runtime: add simple version of instanceof
[mate.git] / tests / InstanceOf1.java
diff --git a/tests/InstanceOf1.java b/tests/InstanceOf1.java
new file mode 100644 (file)
index 0000000..faf3dd9
--- /dev/null
@@ -0,0 +1,17 @@
+package tests;
+
+public class InstanceOf1 {
+       public static void main(String []args) {
+               Instance1 x = new Instance1();
+               if (x instanceof Instance1) {
+                       System.out.printf("x is instance of Instance1 :-)\n");
+               } else {
+                       System.out.printf("x is *not* instance of Instance1 :-(\n");
+               }
+               if (x instanceof Instance2) {
+                       System.out.printf("x is instance of Instance2 :-)\n");
+               } else {
+                       System.out.printf("x is *not* instance of Instance2 :-(\n");
+               }
+       }
+}