java - Hashmap (alternative) with just 1 entry -


i've got set up, want have string saved, date attached it.

private hashmap<string, date> = new hashmap<string, date>(); 

the problem i'm having want 1 thing inside hashmap, when put new string, date in, old 1 gets removed.

i've got myself calling clear before add one, came on different problem:

string current = something.get ???? 

as see above, want 1 entry inside. without date.

is there better alternative? or seeing wrong?

you can use pair<k,v>:

a convenience class represent name-value pairs.

// import statement import javafx.util.pair;  pair<string, date> = new pair<>("string1", new date()); 

and can use

something.getkey() string, & something.getvalue() date.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -