在下文中,是否有更好的方法来初始化acc
?
// . . .
private DoubleBinding acc = new SimpleDoubleProperty(0).add(0);
public void append(ObservableDoubleValue delta){
// . . .
acc = acc.add(delta);
}
答案 0 :(得分:2)
您可以使用Bindings
类(createDoubleBinding
)中的实用程序创建error: Grunt :: (node) warning: possible EventEmitter memory leak detected. 11 change listeners added. Use emitter.setMaxListeners() to increase limit.
error: Grunt :: Trace
at StatWatcher.addListener (events.js:239:17)
at Object.fs.watchFile (fs.js:1424:8)
at Gaze._pollFile (/home/ketys/batn/node_modules/gaze/lib/gaze.js:329:10)
at /home/ketys/batn/node_modules/gaze/lib/gaze.js:411:12
at Array.forEach (native)
at /home/ketys/batn/node_modules/gaze/lib/gaze.js:409:11
at iterate (/home/ketys/batn/node_modules/gaze/lib/helper.js:52:5)
at /home/ketys/batn/node_modules/gaze/lib/helper.js:61:11
at /home/ketys/batn/node_modules/gaze/lib/gaze.js:420:5
at iterate (/home/ketys/batn/node_modules/gaze/lib/helper.js:52:5)
:
DoubleBinding
参数是一个返回绑定值的函数。在这种情况下,假设Java 8,该函数返回常量值0.请注意,此private DoubleBinding acc = Bindings.createDoubleBinding(() -> 0d);
不会绑定到任何DoubleBinding
。