Skip to content

Instantly share code, notes, and snippets.

@knightpop
Created July 12, 2017 17:41
Show Gist options
  • Save knightpop/9ef010affe746cb062bf2b8795cc7824 to your computer and use it in GitHub Desktop.
Save knightpop/9ef010affe746cb062bf2b8795cc7824 to your computer and use it in GitHub Desktop.
Java Variance Test
package org.ktz.example.blog;
import java.util.ArrayList;
import java.util.List;
public class Variance {
public static void main(String[] args) {
String str = "";
Object obj = str;
List<String> listStr = new ArrayList<>();
// List<Object> objects = listStr; // compile error
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment