What do these parentheses mean when calling an object?

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=88050&siteId=1