Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Foo
- {
- private int x;
- public Foo()
- {
- this(1);
- }
- public Foo(int x)
- {
- this.x = x;
- }
- }
- public class Cons {
- public Cons() {
- this(madeUpArg1Value,madeUpArg2Value,madeUpArg3Value);
- }
- public Cons(int arg1, int arg2) {
- this(arg1,arg2, madeUpArg3Value);
- }
- public Cons(int arg1, int arg2, int arg3) {
- // Largest constructor that does the work
- this.arg1 = arg1;
- this.arg2 = arg2;
- this.arg3 = arg3;
- }
- }
- public class Cons {
- public static Cons newCons(int arg1,...) {
- // This function is commonly called valueOf, like Integer.valueOf(..)
- // More recently called "of", like EnumSet.of(..)
- Cons c = new Cons(...);
- c.setArg1(....);
- return c;
- }
- }
Add Comment
Please, Sign In to add comment