5 ms·
Java is notorious as it has very clumsy syntax. Simple arraylist of dictionaries declaration looks like this: ArrayList<Map<String,Object>> myArrayList = new A
by ardit33 9y ago
Java is notorious as it has very clumsy syntax. Simple arraylist of dictionaries declaration looks like this:
ArrayList<Map<String,Object>> myArrayList = new ArrayList<Map<String,Object>>();
Could have been just:
ArrayList<Map<String,Object>> myArrayList = new();
or even better:
ArrayList<Map> = new(); <- if you don't care what the type of map is.
- conwaysgame 9y agoNote in Java8, you could just use: ArrayList<Map<String,Object>> myArrayList = new ArrayList<>();
- shock 9y agoThe diamond operator is available since Java 7. Tripped me up too.
- deleted 9y ago[deleted]
- kuschku 9y agoThat is almost literally what Java does. ArrayList<Map> myArrayList = new ArrayList<>(); works already today.
- blauditore 9y agoAs others have mentioned, there's the diamond operator which has been around since Java 7. > if you don't care what the type of map is You can use raw types, it works perfectly fine (just generates a compiler warning). For explicitly being unspecific, you can also use a type wildcard (`?`).