In java how can i create a class holding multiple records or values of any type to its instance ?
For example, MyDataset<AnyType>, will be holding multiple values of type AnyType.
How should I create MyDataset class, so that when I create an instance of MyDataset, I could add records or values to it of one type a time ?
So that later I could iterate MyDataset<AnyType> to get values.
List<Anytype>?public class MyClass<T>and include a genericList<T>within it. Then when creating instances, declare with the concrete type. This should all be well explained in most any introduction to generic use in Java tutorial.implement Iterable<T>and return your list's iterator in theiterator()method.