final Multimap<String, Map.Entry<Integer, Integer>>[] actionMap = new Multimap[]{null};
final boolean[] loaded = {false};
db.execute(connection -> {
PreparedStatement statement = null;
ResultSet resultSet = null;
actionMap[0] = ArrayListMultimap.create();
try {
statement = connection.prepareStatement("Blah Blah...
while (resultSet.next()) {
final String name = ...
actionMap[0].put(name, new AbstractMap.SimpleEntry<>(int1, int2));
I have a map where I use SimpleEntry
to insert two integer values (int1, int2). On a duplicate key I want to merge values of what's already mapped. My idea is computeIfPresent
but I have no idea of the BiFunctions since I'm using AbstractMap.SimpleEntry
to enter the two values. Any help would be much appreciated.
question from:
https://stackoverflow.com/questions/65930821/merging-values-contained-by-key-in-a-map-java 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…