I am trying to implement the System.exit(0);
in java to terminate my program when the word "exit" is typed into the console. I wrote the following method:
public static void exit(){
Scanner input = new Scanner(System.in);
Str1 = input.next(String);
if (str1 = "exit"){
System.exit(0);
}
else if (str1 = "clear"){
System.out.println("0.0");
}
}
and it doesn't seem to be working. Does anyone have any suggestions?
Thanks P.S the "clear" is just supposed to return 0.0 when "clear" is entered into the console, if you could not already tell.