Function Return writing style in Java

后端 未结 5 1031
眼角桃花
眼角桃花 2020-12-06 16:08

Is this :

String function() { return someString; }

Any different than this ?

String function() { return(someString); }
         


        
5条回答
  •  萌比男神i
    2020-12-06 17:11

    The return with parentheses is not 'calling the return function with an argument', it is simply putting parentheses around the value of the return statement. In other words it is just like writing:

    a = (b + c);
    

    instead of

    a = b + c;
    

    It's perfectly legal but it doesn't add anything useful. And convention is that you don't write the parentheses.

提交回复
热议问题