| Author |
Question about local variables in switch
|
Arsineh Keshishian
Greenhorn
Joined: Apr 21, 2008
Posts: 19
|
|
Hi, When running this code: int n = 4 final int x = 3; final int y = 4; I'M getting a compiler error because of j using in case y. The compiler complains that "j may have not been initialized yet". But I can not reinitialize j either because of "duplicate local variable j". So the only way is to make j final in case x: final int j = 0; Why does j has to be final? Thank you Arsineh
|
 |
Ravikanth kolli
Ranch Hand
Joined: Feb 10, 2008
Posts: 179
|
|
|
do you have a global variable "j"?
|
-kolli
|
 |
 |
|
|
subject: Question about local variables in switch
|
|
|