次のコード サンプルは 2 つのランダム値を作成しますか、それとも最初の値を再利用しますか?
Random r = new Random();
int[] a = new int[10];
a[r.nextInt(10)] += 1;
// Equals this, creating two random values:
a[r.nextInt(10)] = a[r.nextInt(10)] + 1;
// Or this, using 6 as the result of the first random operation
a[6] = 6 + 1;
編集: 作業中ですが、この演算子 (および 、 などの他の演算子-=
)/=
には名前がありますか?