Several questions about ArrayList

Category: J2ME
 
saber_tr
2010-01-27 12:17:59

Sponsored Links
I am not very clear ArrayList usage

first declared private ArrayList billItems = new ArrayList ();

added as follows: (from the database read data is displayed in the drop-down list, the drop-down list to add the selected information added billItems in)
private void appetizerJComboBoxItemStateChanged (ItemEvent event) {
if ((event . getStateChange () == ItemEvent.SELECTED) &&
(appetizerJComboBox.getSelectedIndex ()! = 0))
{
appetizerJComboBox.setEditable (false) ;

billItems.add ((ArrayList) appetizerJComboBox.getSelectedItem ());

}
This code}
have questions? billItems (ArrayList type) in what form the data stored?

there is a do not know how to query the database to retrieve billItems (ArrayList type) in the corresponding data?

Sponsored Links

yiyang4225
2010-01-27 12:26:25

ArrayList Object type can be stored inside each cell are stored Object type, number index from the beginning of the form subscript 0 store

/ / recommend using iterators
for (Iterator iter = list.iterator (); iter.hasNext () ;) {
Object element = (Object) iter.next ();
}

or just use the most common method

for (int i = 0; i <list.size (); i + +) {
Object element = list.get (i);
}

I am also a novice ^ ^ , the code has no error problem did not see it
Iwillgo909
2010-01-27 12:30:03
billItems.add ((ArrayList) appetizerJComboBox.getSelectedItem ());

this billItems kept inside is another ArrayList format data type
lsl19199
2010-01-27 12:32:28
depends appetizerJComboBox.getSelectedItem () return value type, from the point of view is the singular form of the name, it should be a return to a selected record
billItems.add (appetizerJComboBox. getSelectedItem ());
not strongly typed conversion, should be able to

changwwl
2010-01-27 12:35:03
dynamically modify the contents of the data for more cases, it is recommended to use to wrap DefaultComboBoxModel data, and the other: it is best to use using the Connection generic
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.