If i have an object with like 50 methods.
And on another class, i needed to store this object and use 2 of these 50 methods.
Does creating an interface with 2 methods and casting the original methods to it saves space?
I mean in this case, will the interface reference contains 50 methods, or will it delete all the methods that are not in the interface and use the needed ones?
The same with abstract classes.
I am a little confused about the refrences, if i used a reference of a small interface with 2 methods to store a class with 50 methods , does that have any benefit .
Here is why i am asking, i see this example in android studio many times:
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
CreatedInterface object = (CreatedInterface) context;
}
catch (ClassCastException e){
Log.i(TAG , "on attach failed ");
}
}
They never store the entire context refrence, they create an interface with a subset of it.