Parcelable Creator Syntax

AppDeveloper :

Can someone please elaborate on the syntax for Parcelable CREATOR here. for instance it's a static final property, but then I see a class like constructor for a Generic parameter, but no definition of class anywhere, please explain.

public static final Creator<Foo> CREATOR = new Creator<Foo>() {
    @Override
    public Foo createFromParcel(Parcel in) {
        return new Foo(in);
    }

    @Override
    public Foo[] newArray(int size) {
        return new Foo[size];
    }
};
Matt Berteaux :

This is the syntax to instantiate an instance of an anonymous class, which implements the Creator interface. This page has more information on anonymous classes

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=24739&siteId=1