warning appears when using generic types and inheritance

I created an abstract class of general type variables which other type (boolean, char, int) classes extend. I made a static method that creates these variables according to a given string, but I keep getting the warning "reference to generic type should be parameterized". I know why this is happening, but I don't know how to solve this problem. Any help?

public static  Variable createVariable(String variableString) {
    switch (variableString) {
        case "int":
            return new IntVariable(variableName, variableValue);
        case "double":
            return new DoubleVariable(variableName, variableValue);
        case "char":
            return new CharVariable(variableName, variableValue);
        case "String":
            return new StringVariable(variableName, variableValue);
        case "boolean":
            return new BooleanVariable(variableName, variableValue);
        default:
            throw new VariableException();
    }
}

public abstract class Variable<T>{ ... }

public class StringVariable extends Variable<String>{ ... }

public class DoubleVariable extends Variable<Double>{ ... }

public class IntVariable extends Variable<Integer>{ ... }
Jon Skeet
people
quotationmark

I suspect you just need to change the return type of the method:

public static Variable<?> createVariable(String type)

That basically says, "I'm returning a variable of some type, but I have no information about what the type argument is."

people

See more on this question at Stackoverflow