serialization ArrayList Java

Nixit Patel picture Nixit Patel · Jan 9, 2012 · Viewed 45k times · Source

I want to serialize the Arraylist of type ArrayList<Class> and the class contains two Arraylist of primitive type

public class Keyword {

    private long id;
    private long wid;
    private String name;
    private ArrayList<Integer> rank;
    private int month;
    private float avg;
    private ArrayList<String> date;
        ... and so on
}

How can i do that?

Lots of thanks in advance

Answer

Ivaylo Petrov picture Ivaylo Petrov · Jan 9, 2012

If you want to use Serializable, you should have no problems, because ArrayList is Serializable just as String and every primitive type. public class Keyword implements Serializable {} should do. You can read more about this method here. However there are a lot of other options for serialization. So please be more specific.