title: Preferred way of getting the selected item of a JComboBox
body: <p>HI,</p>
  
  <p>Which is the correct way to get the value from a JComboBox as a String and why is it the correct way. Thanks.</p>
  
  <pre><code>String x = JComboBox.getSelectedItem().toString();
  </code></pre>
  
  <p>or</p>
  
  <pre><code>String x = (String)JComboBox.getSelectedItem();
  </code></pre>