-4

Is there a method like the rng.randint() in the code below for Java?

Are Math.random() o java.util.Random viable for this aim?

  ...  

  rng.seed(random_seed)

  child1, child2 = parents

  const1 = child1.const_set
  const2 = child2.const_set

  cp1 = rng.randint(1, len(const1) - 1) if len(const1) > 1 else 0
  cp2 = rng.randint(1, len(const2) - 1) if len(const2) > 1 else 0
Fred_2
  • 249
  • 2
  • 11

1 Answers1

1

new Random().nextInt(<specify bound here>)

If bound is 5, it will give you a random int less than 5

humblefoolish
  • 409
  • 3
  • 15