But it's not the only way. Listing 9 shows another way to configure the FrogMan class.
但这不是唯一的方式。
If you don't ask Guice to create FrogMan, the annotation has no effect on the code's behavior.
如果不要求Guice构建FrogMan,这个注释对代码行为就没有任何影响。
If you think Guice's decision to access private methods seems intrusive, wait until you see Listing 10, in which FrogMan USES field injection.
如果您认为Guice访问私有方法不是很好,可以参见清单10,其中FrogMan使用了字段注入。
The one who took the dishpan, of course, "replied the Frogman, and hearing this all the Yips nodded their heads gravely and said to one another".
“当然是拿走烤饼锅的那个人啦,”青蛙人答道。听到他这么一说,周围的耶普人都神情庄重地点着头,互相说道。
To avoid this problem, you can create an interface (for example, Vehicle) and have your FrogMan class accept the Vehicle as a constructor argument, as in Listing 3.
为了避免这个问题,您可以创建一个接口(例如vehicle),使frogman类接受Vehicle作为一个构造函数参数,如清单3所示。
To avoid this problem, you can create an interface (for example, Vehicle) and have your FrogMan class accept the Vehicle as a constructor argument, as in Listing 3.
为了避免这个问题,您可以创建一个接口(例如vehicle),使frogman类接受Vehicle作为一个构造函数参数,如清单3所示。
应用推荐