How do I create a hash table in Java?

后端 未结 8 759
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 12:41

What is the most straightforward way to create a hash table (or associative array...) in Java? My google-fu has turned up a couple examples, but is there a standard way to do t

8条回答
  •  悲&欢浪女
    2021-02-04 13:31

    Hashtable hashTable = new Hashtable<>();
    

    put values ...

    get max

    Optional optionalMax = hashTable.values().stream().max(Comparator.naturalOrder());
    
    if (optionalMax.isPresent())
     System.out.println(optionalMax.get());
    

提交回复
热议问题