need suggestion about "new JRadioButton"
hello,
i'm new in java, and i need suggestion about things below:
which is better:
to use
Code:
private void try {
radiobutton1.setSelected(true);
radiobutton2.setSelected(false);
radiobutton3.setSelected(false);
}
or this one:
Code:
private void setSelectedRadioButtons(JRadioButton[] rb, boolean[] b) {
for (int i=0; i<=rb.length; i++) {
rb[i].setSelected(b[i]);
}
}
private void try {
setSelectedRadioButtons(
new JRadioButton[] { radiobutton1, radiobutton2, radiobutton3 },
new boolean[] { true, false, false }
}
}
currently, i'm using the latter in my program, but i'm afraid that it takes lots of memory or
it's a "not suggested" line of code.
if the latter is ok, then i will use it for other components and properties
thank you