java.util.List l = new java.util.LinkedList(); l.add("a"); l.add("b"); l.add("c"); java.util.List s = l.subList(1, 2); s.add("*"); System.out.println(l); // prints [a, b, *, c] s.remove(0); System.out.println(l); // prints [a, *, c] java.util.List r = l.subList(2,3); r.addAll(s); System.out.println(l); // prints [a, *, c, *]
2010-05-25
Java sub lists
This feaute is there for a while but I did not noticed it. It turns out that java.util.List#subList allows not only read but also manipulate original list just like list slice manipulation in Python but with clumsy syntax:
Subscribe to:
Post Comments (Atom)
On security
My VPS recently got banned for spam which surprised me since none of my soft there sending email. So my first thoughts were that this is a...
-
Why should it be so damn involved? declare done int default 0; declare continue handler for not found set done = 1; open c...
-
There's more to my previous post. The quote is actually not about unnecessary code but about unnecessary features but still pertinent ...
No comments:
Post a Comment