Avoid concrete fields in traits that can't be initialized to suitable default values.
在trait里避免不能用合适的默认值初始化的具体字段。
Note that, in this example, sum must be initialized to an explicit floating-point value; otherwise, all the subsequent computations will be done using integer arithmetic.
注意,在本例中,sum必须被初始化为一个显式的浮点值;否则,所有后续计算都将使用整数运算计算。
Note that, in this example, sum must be initialized to an explicit floating-point value; otherwise, all the subsequent computations will be done using integer arithmetic.
注意,在本例中,sum必须被初始化为一个显式的浮点值;否则,所有后续计算都将使用整数运算计算。
应用推荐