Item 26: Don't use raw types

26. Raw type should not be used

package tryAny.effectiveJava;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

public class GenericsTest1 {

    public static void main(String[] args) {
        final Collection stamps = Arrays.asList(new Stamp(), new Stamp(), "");
        //The following code will detect it as a compile error.
        // final Collection<Stamp> stamps = Arrays.asList(new Stamp(), new Stamp(), "");
        for (Iterator i = stamps.iterator(); i.hasNext();) {
            Stamp stamp = (Stamp) i.next(); //Send an error when casting the third element. Only known at run time.
            System.out.println("cast success");
        }
    }

    static class Stamp {

    }
}