[Solved] What is the difference between =+ and += [closed]


encryText =+ text;

can be interpreted as

encryText = +text; // positive(text) assigned to encryText

and

encryText += text;

can be interpreted as

encryText = encryText + text; // encryText is added with text and assigned back to encryText

positive(text) – means a positive integer. You’re just explicity specifying the sign here. Usually, the positive integers are specified without the + symbol.

1 – positive number 1 (even without + symbol, it means positive integer 1)

+1 – positive number 1, the + symbol is specified explicitly (nothing different than the above, other than explicit +)

-1 – negative number 1, the - symbol is required to tell that its a negative integer.


Edit:

You edited your question and completely changed the context here(which is totally not done). Nevertheless, in case both are strings,

encryText += text;

can be interpreted as

encryText = encryText + text; // String concatenation happens here

and

encryText =+ text; – would give you a compilation error. You can’t use + on a string as such. Its not valid operation which can be performed on a String in java.

7

solved What is the difference between =+ and += [closed]