泛型还可以用于内部类以及匿名内部类
class Customer{
private static long counter=1;
private final long id=counter++;
private Customer(){}
public String toString(){return "Customer"+id;}
public static Generator<Custom> generator(){
return new Generator<Customer>(){
public customer next(){return new Customer();}
};
}
class Teller{
private static long counter=1;
private final long id=counter++;
private Teller(){}
public String toString(){return "Teller"+id;}
public staic Generator<Teller> generator=nw Generator<Teller>{
public Teller next() { return new Teller();}
}
}