I am tryiing to make a hangman game in Java, but I am having problems initializing a variable lStorage. I have added String[] lStorage,but still not initializing.
switch(difficulty){
case 0:
String[] easywords= new String[]{"integer","project","octopus"};
int wrong = 12;
String[] lStorage;
String easyrnd = (easywords[new Random().nextInt(easywords.length)]);
System.out.println("The word has " + easyrnd.length() + " Letters");
while(wrong>=0){
System.out.println("\n guess a letter");
String letterguess = consolereader.nextLine();
if(easyrnd.contains(letterguess)){
System.out.println("correct " + letterguess + " is the " + "...number" + "Letter"); //need to put in number of letter
for(int i=12;i>0;i--){
lStorage[i]=letterguess;
}
lStoragevariable, mind you. Where do you think you assign it a value?String[] lStorage;" it says that the variable hasn't been initialised, even though it has" The variable has been declared, not initialized.String[] lStorage;is inside theswitchstatement, unless you explicitly declare it, it is not initialized.