Sublist not Serializable

I guess this was already known by some, but I didn’t know that if you sublist a List that was Serializable, you will get back a list that is not.

import java.util.ArrayList;
import java.util.List;

public class SerializableSubListTest {
   public static void main(String[] args) {
     List list = new ArrayList();
     list.add(new Serializable(){private static final long serialVersionUID = 1L;});

     System.out.println("list instanceof Serializable = " + (list instanceof Serializable));

     List subList = list.subList(0, 1);

System.out.println("subList instanceof Serializable = " + (subList instanceof Serializable));

list instanceof Serializable = true
subList instanceof Serializable = false

List App

I have an idea for an online list making app. The list can be sorted on any number of attributes (or “sorts”). Attributes can be added at any time and once “activated” you can drag and drop your list to the order you want for that attribute. Then, if you go to another attribute, it again can be drag and dropped into order, but the order is remembered. So if you go back to the first attribute, the items are resorted based on that attribute.

Continue reading