 <p>Another possible solution is to add a constructor parameter and have a factory method;</p> <pre><code>public class Something extends SomethingElse { private Something(int arg) { super(arg); } public static Something getSomething() { return new Something(new Random().nextInt(10) + 5); } } </code></pre>