title: How to place value at random locations in an array using Math.random?
body: <p>i have an array called Events.</p>
  
  <pre><code>String[] Events = new String[20];
  </code></pre>
  
  <p>How can I write a method to place 10 random events into this array using math.random() only? My attempt to solving the question is this: I'm new and still learning moving from python to java, stress much. </p>
  
  <pre><code>public static void AddRandomEvents(Events[] event) {
      for(int i = 0; i &lt; event.length; i++){
          int rand = (int) (Math.random() + 10) + 1;
          System.out.println(event[rand]);
      }
  }
  </code></pre>
  
  <p>I had a class called events and thats why its Events[]</p>
  
  <p>Any help or contribution would be helpful. Thanks.</p>
  
  <p>Also adding, I'm placing 10 random events from this array</p>
  
  <pre><code>String[] names = {"Wedding", "Birthday", "Funeral","Clubbing","Anniversary", "Volunteer", "Job fair"};
  </code></pre>
  
  <p>to the events array, how to? thanks</p>