Here you can find the source of putNotDup(Map
private static void putNotDup(Map<String, String> tbl, String key, String value)
//package com.java2s; /*//from w w w.ja v a 2s . com * Copyright 2011-2016 ZXC.com All right reserved. This software is the confidential and proprietary information of * ZXC.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into with ZXC.com. */ import java.util.Map; public class Main { private static void putNotDup(Map<String, String> tbl, String key, String value) { if (tbl.containsKey(key)) { String v = tbl.get(key); if (!contains(v, value)) { tbl.put(key, v + "," + value); } } else { tbl.put(key, value); } } private static boolean contains(String py, String unit) { if (!py.contains(unit)) { return false; } String[] splits = py.split(","); for (String s : splits) { if (s.equals(unit)) { return true; } } return false; } }