What is the difference between += and =+?

后端 未结 9 1661
夕颜
夕颜 2020-12-03 14:07

What is the difference between += and =+? Specifically, in java, but in general also.

9条回答
  •  渐次进展
    2020-12-03 15:07

    The += operation as you said, is used for increment by a specific value stated in the R value.Like,

    i = i+1;
    //is equivalent to 
    i += 1;
    

    Whereas, =+ is not any proper operation, its basically 2 different operators equal and unary plus operators written with each other.Infact the + sign after = makes no sense, so try not to use it.It will only result in a hocum.

    i =+ 1;
    //is equivalent to
    i = +(1);
    

提交回复
热议问题