PhiSe :
Just came across this statement and was wondering why this function call had what at first looked like a cast?
SomeClass bo = new SomeClass(); // blabla something like that to initialize the object variable
(bo).setValue(bo.getValue().negate());
As I have not yet seen this syntax - what does it do compared to a simple
bo.setValue(bo.getValue().negate());
?
Andrew Tobilko :
(bo).setValue(bo.getValue().negate())
and bo.setValue(bo.getValue().negate())
are identical statements and the parentheses are reduntant here.
They are needed though when we write expressions like
Object o;
(o = new Object()).toString(); // class java.lang.Object
If we had omitted them,
Object o;
o = new Object().toString(); // class java.lang.String