Pairs and tuples are not built-in to java.
Code from USACO guide to create own generic Pair Class: https://usaco.guide/bronze/intro-ds?lang=java
static class Pair<K, V> {
K first;
V second;
public Pair(K first_value, V second_value) {
first = first_value;
second = second_value;
}
}
Is there a way to create an array of generic types? I’m receiving a generic array creation error when I try doing this:
Pair<Integer, Integer>[] rs = new Pair<Integer, Integer>[N];
I could just create a non-generic Pair class but I was just curious.