1) What has changed?
We just added "Adapter" class which implements LibraryOne and inheriting from LibraryTwoImpl.
As "Adapter" implements "LibraryOne" we easily replace object of "LibraryOneImpl" with object of "Adapter" class.
public class Adapter extends LibraryTwoImpl implements LibraryOne
public void doAB()
2) What we achieved?
Don't changing client code and libraries at all in nice way we replace using "LibraryOne" with "LibraryTwo"
public class Client
public void doSomething(LibraryOne libraryOne)
3) Is it exist another solution?
Yes, in this solution we use inheritance of implementation in Adapter. This "Adapter" is called "class adapter".
Please let's see step3 and show alternative solution called "object adapter".