Bug in Netbeans Java compiler?
I think Netbeans (or Java itself?) has a major flaw in its compiler design.
Explain to me why the following code is not compilable. Specifically, why it should complain about line 8:
cannot find symbol
symbol : variable Selected
When I clearly declared it a couple lines above it!
Now the fact that it was declared in an "If" clause is a lame excuse, because there is an unconditional Else clause which ALSO declares the same Object array. So either way, the Object array gets declared exactly ONCE. Not zero, not twice. In
EVERY SINGLE LOGICAL CASE.
So why was someone on crack when they designed Java/Netbeans? This is a BS error.
1if (president.compareTo("Bush") == 0){
2Object Selected[] = listWarCriminals.getSelectedValues();
3}
4else{
5Object Selected[] = listPresidents.getSelectedValues();
6}
7
8for (int n=0; n<Selected.length; n++){
9name = Selected[n].toString();
10 JOptionPane.showMessageDialog(frame, name,"Result", JOptionPane.INFORMATION_MESSAGE);
11}
>

