Skip to content
Advertisement

Java name generator variable is already defined in method main(String[]) [closed]

I am new, having a problem with my code. I wonder how will I be able to print a variable after the if statements. When I don’t put the variable before the if statement it says that it’s not initialized. here is the code:

JavaScript

public class NameGenerator { public static void main(String[] args) {

JavaScript

}

Advertisement

Answer

First of all, you assign variable only 1 time ” String xmas2 = null;”

JavaScript

Output

JavaScript
Advertisement