package week12; class Pair { final A first; final B second; Pair(A first, B second) { this.first = first; this.second = second; } // these getters doesn't seem to be needed, stdlib doesn't usually use getters for final values and instead just makes them public to be used directly public A getFirst() { return first; } public B getSecond() { return second; } public Pair swap() { return new Pair(second, first); } public Pair withFst(C first) { return new Pair(first, second); } public Pair withSnd(C second) { return new Pair(first, second); } }