For example I have this Hashmap:
Map<String,Integer> map = new HashMap<>();
Instead of doing map.put("A",0)
, map.put("B",0)
... until map.put("C",0)
, is there any way we can make it fast?
Do it in for loop:
for (char ch = 'A'; ch <= 'Z'; ++ch)
map.put(String.valueOf(ch), 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With