Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;

import java.util.List;
import java.util.Map;

public class Main {

    public static <K, V> List<K> getKeyListByIndexes(Map<K, V> map, int[] indexes) {
        if ((indexes == null) || (indexes.length == 0)) {
            return null;
        }
        List<K> keyList = new ArrayList<K>(indexes.length);

        int i = 0;
        for (K key : map.keySet()) {
            for (int index : indexes) {
                if (i == index) {
                    keyList.add(key);
                }
            }
            i++;
        }
        return keyList;
    }
}