kod Google za Guava będzie wyglądać następująco:
import com.google.common.collect.Table;
import com.google.common.collect.HashBasedTable;
Table<String, String, Integer> table = HashBasedTable.create();
for (int i = 0; i < 10; i++) {
table.put("abc", "def", i);
}
Kod powyżej wybuduje HashMap wewnątrz HashMap z konstruktora, który wygląda tak:
Table<String, String, Integer> table = Tables.newCustomTable(
Maps.<String, Map<String, Integer>>newHashMap(),
new Supplier<Map<String, Integer>>() {
@Override
public Map<String, Integer> get() {
return Maps.newHashMap();
}
});
W przypadku, gdy chcesz zastąpić struktury bazowe można łatwo zmienić.
Jaki jest związek między tymi trzema wartościami? – Attila
Przychodzą one dynamicznie z JTextFields i JButtons. – user1170330
Dobrze, ale czy chcesz z nimi zrobić _? – Attila