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<String, String> swapStrKeysAndStrValues(Map<String, ?> hm) {
        HashMap<String, String> nhm = new HashMap<String, String>();
        Set<?> s = hm.entrySet();
        Iterator<?> it = s.iterator();
        while (it.hasNext()) {
            Map.Entry m = (Map.Entry) it.next();
            nhm.put((String) m.getValue(), (String) m.getKey());
        }
        return nhm;
    }
}