samples/erasure/src-api2.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-api2.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.v2
    10     public static boolean arePositive(Set<? extends Number> numbers) {
    11         for (Number n : numbers) {
    12             if (n.doubleValue() <= 0.0d) {
    13                 return false;
    14             }
    15         }
    16         return true;
    17     }
    18     // END: variance.erasure.v2
    19 }