Search code examples
javaandroidinterfacearraylistfinal

Eclipse keep telling me remove final modifier of arraylist


I have a arrayList= new ArrayList<FriendsData>(); that is define inside an interface in my Base Activity.

public interface RequestUsers
    {
        ArrayList<FriendsData> arrayList    =  new ArrayList<FriendsData>();

    }

I already tried cleaning and restarting eclipse but nothing happens.

Please expain why -1 I will remove my question if you think I am stupid as compared to people here at STACKOVERFLOW.


Solution

  • A variable in an interface can only be a constant (i.e. static final). Even so, it is oft considered poor style to have fields in interfaces.

    An alternative is to have an abstract class as opposed to the interface if you genuinely need it in the superclass as opposed to individual extending instances.