Design classes/interface to support methods returning different types
- by Nayn
Hi,
I have classes as below.
public interface ITest <T>
{
public T MethodHere();
}
public class test1 implements ITest<String>
{
String MethodHere(){
return "Bla";
}
}
public class test2 implements ITest<Integer>
{
Integer MethodHere(){
return Integer.valueOf(2);
}
}
public class ITestFactory {
public static ITest getInstance(int type) {
if(type == 1) return new test1();
else if(type == 2) return new test2();
}
}
There is a warning in the factory class that ITest is used as raw type. What modification should I do to get rid of it?
Thanks
Nayn