Advertisement
cd62131

ShuffleMap

Aug 10th, 2017
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.82 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3. import java.util.List;
  4. import java.util.Map;
  5. import java.util.TreeMap;
  6.  
  7. public class ShuffleMap {
  8.     public static Map<Integer, String> map;
  9.     public static String analysis;
  10.     static {
  11.         map = new TreeMap<>();
  12.         map.put(0, "夢");
  13.         map.put(1, "花");
  14.         map.put(2, "亀");
  15.         map.put(3, "猿");
  16.         map.put(4, "女");
  17.         map.put(5, "寝");
  18.         map.put(6, "金");
  19.         map.put(7, "性");
  20.         map.put(8, "食");
  21.         map.put(9, "飲");
  22.         map.put(10, "太");
  23.     }
  24.  
  25.     protected static void getAnalysis() {
  26.         List<String> list = new ArrayList<>();
  27.         list.addAll(map.values());
  28.         Collections.shuffle(list);
  29.         analysis = String.join(" ", list);
  30.     }
  31.  
  32.     public static void main(String[] args) {
  33.         System.out.println(map);
  34.         getAnalysis();
  35.         System.out.println(analysis);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement