2021222324252627
for (int i=0; i<list.size(); ++i) if (list.get(i).key.equals(key)) { list.get(i).setValue(n); return ; } list.add(new Pair(key,n)); //throw new Exception("Element with the given key not found"); }