看看这个例子:
class Parent{
Child child = new Child();
Random r = new Random();
}
class Child{
public Child(){
//access a method from Random r from here without creating a new Random()
}
}
Run Code Online (Sandbox Code Playgroud)
如何从Child对象中访问Random对象?