title: Random weighted selection in Java
body: <p>I want to choose a random item from a set, but the chance of choosing any item should be proportional to the associated weight</p>
  
  <p>Example inputs:</p>
  
  <pre><code>item                weight
  ----                ------
  sword of misery         10
  shield of happy          5
  potion of dying          6
  triple-edged sword       1
  </code></pre>
  
  <p>So, if I have 4 possible items, the chance of getting any one item without weights would be 1 in 4.</p>
  
  <p>In this case, a user should be 10 times more likely to get the sword of misery than the triple-edged sword.</p>
  
  <p>How do I make a weighted random selection in Java?</p>