The compiler can never be sure that hand actually initialized. You must either initialize it earlier or set it to null , so you will bypass this compiler check.
So you could do it, but it's really bad practice! When changing the code, you can get a NullReferenceException !
String[] hand = null;
You know that your code doesnβt actually work, as you end up with one array. I think you mean this:
hand = new String[6]; ... hand[i] = theValue;
source share