instanceof operator in java for comparing different classes
I was trying to see how instanceof operator in Java works and am facing a very odd issue. public static void main(String[] args) { Map m = new HashMap(); System.out.println("m instanceof Date: " + (m instanceof Date)); } The above returns false as expected. However, public static void main(String[] args) { HashMap m = new HashMap(); System.out.println("m instanceof Date: " + (m instanceof Date)); } This does not even compile. I get an error inconvertible types found : java.util.HashMap required : java.util.Date What am I missing here? I am using IntelliJ Idea 11. From the Java Language