Re: How to make a class an alias of another one?



George wrote:
Hi,

I am planning to implement a class (say ClassA) in some special
things. But currently I am not in the stage and it will just be
implement as a String. I can just declare everything in this type

public abstract class ClassA {
// your methods here

public static ClassA getInstance() {
return new Temporary()
}
}

class Temporary extends ClassA {
private String temp;

// implement ClassA methods

}

Now you can declare everything as ClassA and switch implementations when you need easily. Note the lack of "public" on Temporary. It should be in the same package as ClassA.



.



Relevant Pages