title: More effective method then Switch in Android development (Java)
body: <p>I am developing a game in Android Studio (Java). In my project there is a method which is used to generate instances of an object and populate them in an ArrayList. Basically what it does, it just makes "enemy space ships" to shoot at the player "randomly". In other words, after every frame the method generates a random number and if the number is 1, then the ArrayList is populated by a "laser blast" object instance which makes the enemy space ship to shoot. </p>
  
  <p><strong>My question would be: Is there a better and less costly way to simulate this kind of event? Or maybe there is a way to make this existing method more efective and less costly?</strong></p>
  
  <p>Here is the method:</p>
  
  <pre><code>public static void generateRandomNumber(ArrayList&lt;EnemyShipLaserBlast&gt; listOfLaserBlasts, int x, int y) 
  {
      Random random = new Random();
      int number = random.nextInt(50);
      switch (number) {
          case 1:
              listOfLaserBlasts.add(new EnemyShipLaserBlast(x, y));
              break;
          default:
              //do nothing
      }
   }
  </code></pre>