总是有jython。
这里有一点来自this article,它提供了python/java的良好并排视图The Jython analogues to Java's
collection classes are much more
tightly integrated into the core
language, allowing for more concise
descriptions and useful functionality.
For example, notice the difference
between the Java code:map = new HashMap();
map.put("one",new Integer(1));
map.put("two",new Integer(2));
map.put("three",new Integer(3));
System.out.println(map.get("one"));
list = new LinkedList();
list.add(new Integer(1));
list.add(new Integer(2));
list.add(new Integer(3));
and the Jython code:map = {"one":1,"two":2,"three":3}
print map ["one"]
list = [1, 2, 3]
编辑:仅仅使用put()替换值有什么问题?
map.put(key,new_value);
下面是一个小的示例程序:static public void main(String[] args){
HashMap map = new HashMap();
//name, age
map.put("billy", 21);
map.put("bobby", 19);
year(map);
for(String i: map.keySet()){
System.out.println(i+ " " + map.get(i).toString());
}
}
// a year has passed
static void year(HashMap m){
for(String k: m.keySet()){
m.put(k, m.get(k)+1);
}
}