Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static void addIntPair(Map map, Object key, int value1, int value2) {
        Object o = map.get(key);
        List pair;
        if (o == null) {
            pair = new ArrayList();
            pair.add(new Integer(value1));
            pair.add(new Integer(value2));
            map.put(key, pair);
        } else {
            pair = (List) o;
            List newPair = new ArrayList();
            int new1 = ((Integer) pair.get(0)).intValue() + value1;
            int new2 = ((Integer) pair.get(1)).intValue() + value2;
            newPair.add(new Integer(new1));
            newPair.add(new Integer(new2));
            map.put(key, newPair);
        }
    }
}