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:
Posts (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...
-
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...
-
Parentheses are the first thing any newcomer notices about Lisp program. This is something that put off many who does not want to learn the...