I'm using Java 11 and SonarLint. I have this code for getting a random index in a string (SALTCHARS is a string of length 36)
int index = (int) (rnd.nextFloat() * SALTCHARS.length());
However, using SonarLint, this generates this warning
I can't simply replace "nextFloat" with "nextInt" as that functionally changes the result of this code. What is a SonarLint-safe way of generating a random index in a string?
int index = rnd.nextInt(SALTCHARS.length());