I'd like to ask if anyone knows how can I use the same array in a switch with different values for the different cases without getting error. I have this code:
String [] measures;
switch(option){
case "Distance":
measures= {"Quilometers(km)", "Meters(m)"};
break;
case "Temperature":
measures= {"Celsius(ºC)", "Fahrenheit(ºF), "Kelvin(K)"};
break;
(...)
I'm getting the error "Array initializer is not allowed here" where I have measure={...}
But if I change the code and write inside each case,
String [] measures= {...}
I get the error "Variable measures is already defined in the scope". Can you please help?