I know why use interface and wrapper.
But I confuse to name wrapper class… (“Who is wrapper?” I see I do not know well…)
public Interface A {
void method();
}
public Class B implements A {
void method() {
doSomething();
}
}
I am confused by two things…
Wrapper Class is class , so B is wrapper.
We usually see(or think?) a.method() not b.method(), so A is wrapper.
What is wrapper?
A? B?
And…
How to name A,B good using “Wrapper” or “W”?
A, AWrapper? or B, BWrapper? or others…?
Ais an interface.Bis a concrete implementation ofInterface. Nothing else can be said about them from the code you provided.A Wrapper “wraps” the functionality of another class or API by adding or simplifying the functionality of the wrapped class/API. For example, the Primitive Wrappers from Java add useful methods like
doubleValueandcompareToto Java primitives.You’re thinking of Polymorphism.
That’s what allows us to say things like:
Side note:
InterfaceandClassare not allowed to be capitalize in Java. Your declarations should be like so: