/**
 * Like std::pair
 */

public class Pair<X, Y>
{
    // type erasure: when compiled, X and Y replaced by Object
    private X first;
    private Y second;

    public Pair(X x, Y y)
    {
	first = x;
	second = y;
    }

    public X getFirst()
    {
	return first;
    }

    public Y getSecond()
    {
	return second;
    }

    public String toString()
    {
	return "(" + first.toString() + ", " + second.toString() + ")";
    }
    
    public static void main(String[] args)
    {
	Pair<String, String> p = new Pair<>("James", "Glenn");
	System.out.println(p);

	Pair<Integer, Double> x = new Pair<>(1, 1.5);
	int i = x.getFirst();
	//String i = x.getSecond(); // compile-time check: generates error

	X x;
	Y y;
	y = (Y)x;
	x.foo();
    }
}
    

class Vector<T>
{
    private T[] elements;

    public Vector()
    {
	elements = new T[100]; // can't do this!
    }

    public T get(int i)
    {
	return (T)elements[i];
    }
}
