No, or at least not directly: in Java you cannot inherit an instance; you need to inherit from the class.
However, you can create an anonymous class that wraps the instance returned from the builder. You can call methods on the wrapped instance, as you wish, and override those that you need to override.
final ClassName wrapped = builder.buildClassName(); ClassName c = new ClassName() { public void passedThroughMethod1() { wrapped.passedThroughMethod1() } public void overridenMethod() { method body } public void passedThroughMethod2() { wrapped.passedThroughMethod2() } };
At this point, c behaves like an instance of wrapped , with the exception of overridenMethod . Unfortunately, you cannot access protected wrapped members.
source share