I just made a Java n-tuple which is type-safe.
I\'m using some unconventional methods to achieve type-safety (I just made it for fun).
Can someone can give some
If you're really interested in writing type-safe containers, look into generics:
public class Tuple {
private final T[] arr;
public Tuple (T... contents) {
arr = contents; //not sure if this compiles??
}
// etc
public static final void main(String[] args) {
Tuple stringTuple = new Tuple("Hello", "World!");
Tuple intTuple = new Tuple(2010,9,4);
}
}