title: When to throw runtime exception?
body: <p>Recently, I had interview with company and they gave me a coding problem. I was given program related to deck of cards and one of the methods was to shuffle the deck of cards. So I wrote the program as:</p>
  
  <pre><code>/** Shuffle the list of cards so that they are in random order 
   * @param d Deck of cards*/
  public  static void shuffle(Deck d)
  {
      if(d == null)
          throw new IllegalArgumentException();
      Random randomGenerator = new Random();
      List&lt;Card&gt; cards = d.getDeckOfCards();   // cards is basically Linked List.. cards = new LinkedList&lt;Cards&gt;()
      for(int i=0;i&lt;cards.size();i++)
      {
          int randomNumber = randomGenerator.nextInt(52);
          Card c1 = cards.remove(randomNumber);
          Card c2 = cards.remove(0);
          cards.add(0, c1);
          cards.add(randomNumber,c2);
      }       
  
  }
  </code></pre>
  
  <p>In the above code, I have thrown <strong>IllegalArgumentException</strong> which I'm most doubtful about. Under what conditions should actually throw a runtime exception? Should we actually throw runtime exception?</p>
  
  <p>Thanks</p>