Q:

Java: create instance of variable class

I have interface Cat that is implemented by classes LolCat and FatCat.  My program needs to remember which type of Cat user wanted melt with next.  I cannot instantiate the proper Cat yet, so I need to remember the class.  How do I do this? 

I tried:
Class nextCatClass = FatCat.class;

But now I don't know how to instantiate it using a variable.  new nextCatClass() is not a valid syntax.  I also tried
Class<Cat> nextCatClass = FatCat.class;

but now I get an "incompatible types" error. 

Risking to annoy the heck out of Java users, here's what I'd do in Python:
next_cat_class = FatCat
...
instance = next_cat_class()

A:

You could use lambda Suppliers:
    public static void main(String args[]) {
        Supplier<Cat> lolCatSupplier = LolCat::new;
        Supplier<Cat> fatCatSupplier = FatCat::new;
        Cat lolCat = lolCatSupplier.get();
        Cat fatCat = fatCatSupplier.get();
        System.out.println(lolCat.getClass());
        System.out.println(fatCat.getClass());
    }

