A HashMap
contains more than one key. You can use keySet()
to get the set of all keys.
team1.put("foo", 1);
team1.put("bar", 2);
will store 1
with key "foo"
and 2
with key "bar"
. To iterate over all the keys:
for ( String key : team1.keySet() ) {
System.out.println( key );
}
will print "foo"
and "bar"
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…