W
wee
i'm confused with the way java initializes object arrays:
if i declare array objects as such;
JTextField[] arr_field;
arr_field[0] = new JTextField(10);
arr_field[1] = new JTextField(10);
the compiler reports it as an error, but if i declare it as such;
JTextField[] arr_field = {new JTextField(10), new JTextField(10);
then the complier compiles it. shouldn't they be the same? and also,
why can't i initialize array objects as;
JTextField arr_field[3];
for (int i = 0; i < 3; i++) {
arr_field = new JTextField(10);
}
thanks.. -wee
if i declare array objects as such;
JTextField[] arr_field;
arr_field[0] = new JTextField(10);
arr_field[1] = new JTextField(10);
the compiler reports it as an error, but if i declare it as such;
JTextField[] arr_field = {new JTextField(10), new JTextField(10);
then the complier compiles it. shouldn't they be the same? and also,
why can't i initialize array objects as;
JTextField arr_field[3];
for (int i = 0; i < 3; i++) {
arr_field = new JTextField(10);
}
thanks.. -wee