1. Multimap Example
Download: guava google core library for Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | package javautility; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ListMultimap; import java.io.IOException; import java.util.Collection; public class JavaUtility { static void testMultiMap() { ListMultimap<String, String> map = ArrayListMultimap.create(); map.put("1","A"); map.put("1","a"); map.put("2","B"); map.put("3","C"); Collection<String> list = map.get("1"); list.forEach(System.out::println); } public static void main(String[] args) throws IOException { testMultiMap(); } } |
Result:
A a
댓글 없음:
댓글 쓰기