Java.use(better, Tips);

《前の記事|記事一覧|次の記事》
Java.use(better, Tips);


Tips#064

java.util.HashMap



明日死ぬがごとく生き
永遠に生きるがごとく学べ
Mahatma Gandhi - Wikipedia

《関連記事》

■ INDEX
>>> dir(java.util.HashMap)
['Entry', '__class__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__len__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', 'class', 'clear', 'clone', 'containsKey', 'containsValue', 'empty', 'entrySet', 'equals', 'get', 'getClass', 'hashCode', 'isEmpty', 'keySet', 'notify', 'notifyAll', 'put', 'putAll', 'remove', 'size', 'toString', 'values', 'wait']

 ↑ TOP

■ 事例
$ jython
Jython 2.5.0 (Release_2_5_0:6476, Jun 16 2009, 13:33:26) 
[Java HotSpot(TM) Client VM (Apple Inc.)] on java1.5.0_13
Type "help", "copyright", "credits" or "license" for more information.
>>> # ---------------------------------------- Map
>>> from java.util import HashMap
>>> 
>>> # ---------------------------------------- put
>>> from java.lang import Character
>>> 
>>> m1 = HashMap()
>>> for e in "ABC":
...   m1.put(e, Character.hashCode(e))
... 
>>> print(m1)
{A=65, C=67, B=66}
>>> 
>>> m2 = HashMap()
>>> for e in "XY":
...   m2.put(e, Character.hashCode(e))
... 
>>> print(m2)
{Y=89, X=88}
>>> 
>>> m1.putAll(m2)
>>> print(m1)
{A=65, Y=89, C=67, B=66, X=88}
>>> m1.remove('X')
88
>>> print(m1)
{A=65, Y=89, C=67, B=66}
>>> m1.remove('X')
>>> print(m1)
{A=65, Y=89, C=67, B=66}
>>> 

 ↑ TOP

》作業中です《

update*13/03/04 19:53:22