Okay, this question is based on the following code (from p. 463 of Sierra & Bates, Head First
Java)
public class MySendListener implements ActionListener {
public void actionPerformed(ActionEvent a) {
boolean[] checkboxState = new boolean[256];
for (int i = 0; i < 256; i++) {
JCheckBox check = (JCheckBox) checkboxList.get(i);
if (check.isSelected()) {
checkboxState[i] = true;
}
}
try {
FileOutputStream fileStream = new FileOutputStream(new File("Checkbox.ser"));
ObjectOutputStream os = new ObjectOutputStream(fileStream);
os.writeObject(checkboxState);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
//end of code block
My question is based on the line:
os.writeObject(checkboxState);
Given that checkboxState is an array, shouldn't this be:
os.writeObject(checkboxState[]);
If not, why not?