Skip to content

Instantly share code, notes, and snippets.

@pcdavid
Created July 18, 2009 12:58
Show Gist options
  • Save pcdavid/149550 to your computer and use it in GitHub Desktop.
Save pcdavid/149550 to your computer and use it in GitHub Desktop.
JavaArraysBreakTypeSafety.java
/**
* 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