让
Parent类将自己的实例传递
Random给
Child该类。
class Parent{ Child child; Random r = new Random(); public Parent() { child = new Child(r); }}class Child{ public Child(Random r){ } }经典Occam剃刀。

让
Parent类将自己的实例传递
Random给
Child该类。
class Parent{ Child child; Random r = new Random(); public Parent() { child = new Child(r); }}class Child{ public Child(Random r){ } }经典Occam剃刀。