Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.HashMap;

import java.util.Map;

import java.util.Vector;

public class Main {
    public static <K1, K2, V> Map<K2, V> mapGetOrCreateVector(Vector<Map<K2, V>> vectorOfMaps, int index) {
        Map<K2, V> m = vectorOfMaps.elementAt(index);
        if (null == m) {
            m = newMap();
            vectorOfMaps.add(index, m);
        }
        return m;
    }

    public static <K, V> Map<K, V> newMap() {
        return new HashMap<K, V>();
    }

    public static <K, V> Map<K, V> newMap(int initCap) {
        return new HashMap<K, V>(initCap);
    }
}