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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…