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...
-
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...
-
A useful bug report has all three parts: how to locate or reproduce it, what is actually there and what should there be. I would extend th...
No comments:
Post a Comment