Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>well there's always <a href="http://www.jython.org/" rel="nofollow noreferrer">jython</a>. here's a little bit from <a href="http://www.onjava.com/pub/a/onjava/2002/03/27/jython.html" rel="nofollow noreferrer">this article</a> that offers a good side by side view of python/java</p> <blockquote> <p>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:</p> <pre><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)); </code></pre> <p>and the Jython code:</p> <pre><code>map = {"one":1,"two":2,"three":3} print map ["one"] list = [1, 2, 3] </code></pre> </blockquote> <p><hr/> edit: what's wrong with just using put() to replace the values?</p> <pre><code>map.put(key,new_value); </code></pre> <p>here's a small example program:</p> <pre><code>static public void main(String[] args){ HashMap&lt;String,Integer&gt; map = new HashMap&lt;String,Integer&gt;(); //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&lt;String,Integer&gt; m){ for(String k: m.keySet()){ m.put(k, m.get(k)+1); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload