How to store an object type in a variable, and use it?

So. I have a generated tile map. I want to make it so that when you make it, there will be a variable called “default_tile.” I want to be able to put in a default object that will be copied and used. Until now, I just made a huge class that wen something like this:


public static final int Rock=0, Sand=1;
public static Tile getTileOf(float x, float y, int type) {
if(type == Rock)
    return new Rock(x, y);
if(type == Sand)
    return new Sand(x, y);
}

But that is MESSY! What do I do instead?