两种表示法有什么区别:
encryText =+ text;
和
encryText += text;
注意:encryText和text都是字符串
encryText =+ text;
可以解释为
encryText = +text; // positive(text) assigned to encryText
和
encryText += text;
可以解释为
encryText = encryText + text; // encryText is added with text and assigned back to encryText
positive(text)
-表示正整数。您只是在此处明确指定符号。通常,指定正整数时不带+
符号。
1
-正数1(即使没有+
符号,也表示正整数1)
+1
-正数1,+
符号是明确指定的(除上面明确以外,与上面没有什么不同+
)
-1
-负数1,-
要求该符号表明其为负整数。
编辑:
您编辑了问题,并在这里完全更改了上下文(这完全没有完成)。不过,如果两个都是字符串,
encryText += text;
可以解释为
encryText = encryText + text; // String concatenation happens here
和
encryText =+ text;
-会给您一个编译错误。您不能+
对这样的字符串使用。它是无效的操作,可以在Java中的String上执行。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句