Pairs in java

Hey everyone,

I’m wondering why I’m getting an error when I copy-paste the code on the USACO guide chapter for pairs and tuples.

Could someone help me out?

Either remove “static” or nest the entire Pair class inside Main. More info here.

I think in most IDEs, if you put your cursor over the red line, it tells you what the problem is. So many try that, then make a post here?

This is what I get:


You need to put the pair class inside the Main class.

It should look like this:

public class Main {
    static class Pair<K, V> {
    public static void main(String[] args) {
1 Like

You can put it outside the main class, you just have to remove the static modifier.

1 Like