samples/erasure/src-api1.0/api/Erasure.java
author Jaroslav Tulach <jtulach@netbeans.org>
Tue, 18 Oct 2011 07:10:23 +0200
changeset 380 a2e90b86638a
parent 379 samples/contravariance/src-api1.0/api/Contravariance.java@b632733724a8
child 390 a72eecb99952
permissions -rw-r--r--
One can use covariance and contravariance with generic types due to their erasure
     1 package api;
     2 
     3 import java.util.Set;
     4 
     5 public class Erasure {
     6     private Erasure() {
     7     }
     8 
     9     // BEGIN: variance.erasure.v1
    10     public static boolean arePositive(Set<? extends Integer> numbers) {
    11         for (Integer n : numbers) {
    12             if (n <= 0) {
    13                 return false;
    14             }
    15         }
    16         return true;
    17     }
    18     // END: variance.erasure.v1
    19 }