两种符号之间有什么区别:
encryText =+ text;
Run Code Online (Sandbox Code Playgroud)
和
encryText += text;
Run Code Online (Sandbox Code Playgroud)
注意:encryText和text都是字符串
encryText =+ text;
Run Code Online (Sandbox Code Playgroud)
可以解释为
encryText = +text; // positive(text) assigned to encryText
Run Code Online (Sandbox Code Playgroud)
和
encryText += text;
Run Code Online (Sandbox Code Playgroud)
可以解释为
encryText = encryText + text; // encryText is added with text and assigned back to encryText
Run Code Online (Sandbox Code Playgroud)
positive(text) - 表示正整数.你只是明确指出这里的标志.通常,正整数是在没有+符号的情况下指定的.
1- 正数1(即使没有+符号,也表示正整数1)
+1- 正数1,+显式指定符号(除了显式之外没有什么不同+)
-1- 负数1,该-符号需要告诉它一个负整数.
编辑:
您编辑了您的问题并完全更改了上下文(完全没有完成).不过,如果两者都是字符串,
encryText += text;
Run Code Online (Sandbox Code Playgroud)
可以解释为
encryText = encryText + text; // String concatenation happens here
Run Code Online (Sandbox Code Playgroud)
和
encryText =+ text; - 会给你一个编译错误.你不能+在字符串上使用它.它是无效的操作,可以在java中的String上执行.
| 归档时间: |
|
| 查看次数: |
83 次 |
| 最近记录: |