fork download
  1. import com.google.common.collect.TreeMultimap;
  2. import java.util.SortedSet;
  3. import java.util.ArrayList;
  4. import java.util.Collection;
  5.  
  6. class HelloWorld {
  7. public static void main(String[] args) {
  8. // Create an instance of TreeMultimap
  9. TreeMultimap<Double, Integer> multimap = TreeMultimap.create();
  10.  
  11. // Add some key-value pairs
  12. multimap.put(0.0, 7);
  13. multimap.put(5.6, 2);
  14. multimap.put(2.3, 3);
  15. multimap.put(1.2, 4);
  16.  
  17. // Get a Collection of all values
  18. Collection<Integer> values = multimap.values();
  19.  
  20. // Convert the Collection to a SortedSet
  21. ArrayList<Integer> sortedValues = new ArrayList<>(values);
  22.  
  23. // Print the SortedSet
  24. System.out.println(sortedValues);
  25. }
  26. }
Success #stdin #stdout 0.14s 57572KB
stdin
Standard input is empty
stdout
[7, 4, 3, 2]