We want to obtain a coordinate value randomly in a certain coordinate area on the mobile terminal to calculate the position. However, Random only supports the acquisition of Random numbers within a certain value, but does not support region acquisition. Their own code to achieve a random number can get a certain area, the following is the code:

Public int getRandom(int start, int getRandom) public int getRandom(int start, int getRandom) int end) { int randomNum = (int) (random.nextFloat() * (end - start + 1) + start); // LogUtils.d(TAG, "random(start,end):" + "(" + start + "," + end + ")" + " - randomNum = " + randomNum); return randomNum; }Copy the code

A Random number is generated by multiplying the value of a float by the difference in the range of values.