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.Iterator;
import java.util.Map;

import java.util.Set;

public class Main {
    @SuppressWarnings("rawtypes")
    public static Map<Integer, String> swapStrKeysAndIntValues(Map<String, Integer> hm) {
        HashMap<Integer, String> nhm = new HashMap<Integer, String>();
        Set<?> s = hm.entrySet();
        Iterator<?> it = s.iterator();
        while (it.hasNext()) {
            Map.Entry m = (Map.Entry) it.next();
            nhm.put((Integer) m.getValue(), (String) m.getKey());
        }
        return nhm;
    }
}