Approved Draft Standard for DevOps [IEEE 2675-2021]
standards.ieee.org2 pointsby scorchin0 comments
List<String> myList = new ArrayList<String>();
myList.add("Second Thing");
myList.add("Second Thing");
myList.add("First Thing");
Note that I've used the interface form of List over a specialised type. This is so that any caller of a method which returns a collection can use the interface provided and they don't need to worry about the specific data structures you've used. This also means that you can update the underlying data structure without having to update any calling code. E.g. changing the above case from ArrayList to LinkedList. Set<String> mySet = new HashSet<String>();
mySet.add("Second Thing");
mySet.add("Second Thing");
mySet.add("First Thing");
It is worth noting that Hashtable was not originally part of the Collections framework. It was retrofitted to conform to the Map interface in 1.2. You should instead use HashMap, which is the non-synchronized (sic) version of Hashtable. Although you can just as easily use Hashtable, the below example is just me being a little OCD. Map<String, String> myMap = new HashMap<String, String>();
myMap.put("a", "Second Thing");
myMap.put("b", "Second Thing");
myMap.put("c", "First Thing");
EDIT: Updated some sections to read clearer.