Originally Posted by
copeg
a) Define your class to be Generic
public class TestModel<K>{
b) no need for the generic near the public
public void add(K fieldType, K value)//remove the 'public<K>'
But this is tying down the class type for value at the time the model variable is defined. I was hoping to tie it down to the fieldType parameter at compile-time. Note the two usage examples I had and the expected results:
v.add("hello", new Integer(2)); // There should be a compile-time error here
v.add("hello", "there"); // But not here