0
The sum of any 10 numbers and the sum of the first 10numbers in Java? Difference with code! Thanks
Java
2 Antworten
+ 15
● For generating random number from 0 to a-1 is :
import java.util.Random; //importing Random class
Random ran = new Random(); //Object ran
int x = ran.nextInt(a);
● U didn't spcify how many random numbers to be generated [for example , 100 numbers generated & taken in an array, now take sum of 1st 10 elements & sum of any 10 elements of that array by taking random index]
// & see difference of sums
0
the first alternative can be a universe greater than 10 numbers, it does not specify if adding must be selected in order or random, the second alternative tells you that you must add the first 10, so it tells you an order