Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class A {
- private T1 a;
- private T2 b;
- ...
- // If A is not abstract then this one may be protected since it's complicated.
- A(T1 a, T2 b, ... /* all fields */) {
- this.a = a;
- this.b = b;
- ...
- }
- A(T1 a, T2 b, ... /* some fields omitted */) {
- this(a, b, ... , /* x: */ null, /* y: */ null, /* z: */ null);
- // omitted fields' init
- this.x = new HashMap<>();
- this.y = new HashSet<>();
- this.z = new ArrayList<>();
- }
- A(T1 a, T2 b, ... /* more fields omitted */) { ... }
- ... // and so on.
- /* this may be private when used in a static method(factory)
- or special public init. method for the client. */
- private A() { ... /* all by default */ }
- }
- abstract class B extends A {
- ... // B's fields
- // Again the most complicated one for subclasses/internal used.
- B(T1 a, T2 b, ..., T26 z, ... /* then B's fields */) {
- super(a, b, ... , z); //
- }
- ... // More constructors by the same idea as class A
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement