title: Generate a random integer on an interval
body: <p>So I have this class called Organism:</p>
  <pre><code>public class Organism implements Comparable{
  
      // Represents the organisms guess for the unknown string
      String value;
      // String the organism is trying to guess
      String goalString;
      int n;
  
      public Organism(String goalString) {
          this.goalString = goalString;
          this.value = goalString;
      }
  
      public Organism(String value, String goalString, int n) {
          this.goalString = goalString;
          this.value = value;
          this.n = n;
      }
  
      public int fitness(){
          // Represents the fitness of the organism
          int count = 0;
  
          for(int i = 0; i &lt; goalString.length(); i++) {
              if(value.charAt(i) == goalString.charAt(i)) {
                  count ++;
              }
          }
          return count;
      }
  
      public Organism[] mate(Organism other) {
          // Generate a random integer from [0, n-1]
          int crossOver;
  
  
  
          return new Organism[0];
      }
  
      @Override
      public int compareTo(Object o) {
  
          return 0;
      }
  
      public void mutate(double mutateProb) {
  
      }
  
      @Override
      public String toString() {
          return &quot;Value: &quot; + value + &quot;    &quot; + &quot;Goal: &quot; + goalString + &quot;    &quot; + &quot;Fitness: &quot; + fitness();
      }
  
  
      public String getValue() {
          return value;
      }
  
      public String getGoalString() {
          return goalString;
      }
  
      public int getN() {
          return n;
      }
  
  }
  </code></pre>
  <p>Inside of the mate method I need to generate a random integer on the interval [0, n-1] where n is the length of value and goalString. I then need to store that inside of the crossOver variable inside of the mate method. What would be the best way to do that?</p>