是的
+=,不是
=+
您所做的可能也是有效的代码,但是现在您正在做
avg[0] = + array0[i];
它适用于数字类型(我假设您有)。没有数组索引的简化示例:
int x = +5;
样品:
public static void main(String[] args) { int x = -5; int y = +x; System.out.println(y); // - + => - int a = 5; int b = -a; System.out.println(b); // + - => - int c = 5; int d = +5; System.out.println(d); // + + => + int m = -5; int n = -m; System.out.println(n); // - - => +}输出:
-5
-5
5
5
为了清晰起见,从评论中复制:
您基本上是在说
x = + y。在这种情况下,
+仅需指示它是一个正整数即可。这是有效的代码,但这不是您想要的。



