Created
July 18, 2009 12:58
-
-
Save pcdavid/149550 to your computer and use it in GitHub Desktop.
JavaArraysBreakTypeSafety.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Illustrates a limitation of the Java type system when using arrays. | |
* The code below compiles without warnings but fails at runtime. | |
*/ | |
public class JavaArraysBreakTypeSafety { | |
public static void main(String[] args) { | |
Object[] t = new String[1]; | |
t[0] = new Integer(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment