Just wondering if this is the right way to do it. I want to construct instances of my parametrized class where one of the instance variables is a generic type. The code below works but I get a lot of warnings in the main method "SomeObject is a raw type. References to generic type SomeObject should be parameterized".
public class SomeObject<T> {
private String description;
private T value;
public SomeObject(String description, T value) {
this.description = description;
this.value = value;
}
public static void main(String args[]){
List <SomeObject> objectList = new ArrayList<SomeObject>();
objectList.add(new SomeObject("Object 1: ", true));
objectList.add(new SomeObject("Object 2: ", 888.00));
objectList.add(new SomeObject("Object 3: ", "another object"));
objectList.add(new SomeObject("Object 4: ", '4'));
for (SomeObject object : objectList){
System.out.println(object.getDescription() + object.getValue());
}
}
}