My question is rather simple. Im trying to make a builder for building charts. The chart data will be filled by an object depending on what program my fellow programmers create Therefore ive used an interface called ObjectInterface to make sure that there are certain methods the an object always have.
My question is if i want to add these objects (that i do not know of which type) to an ArrayList is it possible to add them such as this:
ArrayList<ObjectInterface> data = new ArrayList<ObjectInterface>();
ObjectType Test = new ObjectType("Test");
data.add(test);
in this example the ObjectType is an object that implements the ObjectInterface
is this legal ?