Backtrack:  
 
showing posts tagged with 'programming'
 
edited by on May 27th 2015, at 15:25

Preferred:

String x = JComboBox.getSelectedItem().toString();

or

String x = String.valueOf(JComboBox.getSelectedItem());

The second method protects against null values as well.

Avoid using casting:

String x = (String)JComboBox.getSelectedItem();

This would work fine if the item is indeed a string, but will fail if it can (also) be any other data type. To be safe, use either of the first two methods.

edited by on August 13th 2014, at 09:16

A reminder to myself...

Set a bit:

Var |= Bit;

Clear a bit:

Var &= ~Bit;
 
showing posts tagged with 'programming'
 
 
« April 2025»
SunMonTueWedThuFriSat
  12345
6789101112
13141516171819
20212223242526
27282930   
 
Links
 
Quote
« You only find out who is swimming naked when the tide goes out. »
Warren Buffett