Several questions about ArrayList

Category: Java SE
 
yuliangqin
2011-11-03 01:56:36

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

luckybai
2011-11-03 02:32:02
do not understand why you converted? (ArrayList) appetizerJComboBox
appetizerJComboBox is control how it will turn into ArrayList?
Proposal to change:
billItems.add (appetizerJComboBox.getSelectedItem ()); / / Here I assume you The item is a String, otherwise converted to String

ArrayList can save a lot of things, you can save the basic data types, you can also save the class of the object. Regardless of how that it is an ordered sequence. See jdk document
z316158482
2011-11-03 02:58:44
how feeling confused like
peak1hao
2011-11-03 03:28:21
LZ would like to ask what the problem is?
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.