I am trying to get an input from console, assign it to a string variable. Then I'd like to concatinate it with another variable. Provided if the user enters the right character each time, soon it'll make up a word. Once this word matches the desired one the loop stops. Need your help though.
public class expl {
public static void main(String[] args) {
String consatinate = "a";
String needed = apple;
while (!consatinate.equals(needed)) {
System.out.println("Enter a letter");
String input = System.console().readLine();
consatinate = consatinate.concat(input);
System.out.println(consatinate);
}
}
}
Error message:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: apple cannot be resolved to a variable at expl.main(expl.java:6)