Skip to content

Instantly share code, notes, and snippets.

@qrtt1
Created January 14, 2016 05:41
Show Gist options
  • Save qrtt1/355b3bc920e441e0a5db to your computer and use it in GitHub Desktop.
Save qrtt1/355b3bc920e441e0a5db to your computer and use it in GitHub Desktop.
package generic;
import java.util.ArrayList;
import java.util.List;
public class 阿嬤妳今嘛在叨位 {
static class 阿嬤 {
}
static class 淡水的阿嬤 extends 阿嬤 {
}
static class 恁祖媽 extends 淡水的阿嬤 {
}
public void lowerBoundedWildcard(List<? super 淡水的阿嬤> list) {
}
public void upperBoundedWildcard(List<? extends 淡水的阿嬤> list) {
}
public static void main(String[] args) {
阿嬤妳今嘛在叨位 operator = new 阿嬤妳今嘛在叨位();
List<阿嬤> list1 = new ArrayList<阿嬤>();
List<淡水的阿嬤> list2 = new ArrayList<淡水的阿嬤>();
List<恁祖媽> list3 = new ArrayList<恁祖媽>();
operator.lowerBoundedWildcard(list1);
operator.lowerBoundedWildcard(list2);
operator.lowerBoundedWildcard(list3); // compilation-error
operator.upperBoundedWildcard(list1); // compilation-error
operator.upperBoundedWildcard(list2);
operator.upperBoundedWildcard(list3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment