I am writing a program about exchange transactions between different currencies.
At a certain point the program asks the user to input the initial currency and check if the string input by the user is within the values specified by the program:
while (!isSet) {
System.out.println("Give the Initial Currency: USD | EUR | GBP | JPY | CHF | CAD | AUD");
start_currency = scanner2.nextLine();
if ((start_currency != "USD") && (start_currency != "EUR")
&& (start_currency != "GBP") && (start_currency != "JPY")
&& (start_currency != "CHF") && (start_currency != "CAD")
&& (start_currency != "AUD")
) {
System.out.println("Please choose a value from the initial currencies specified above!");
} else {
isSet = true;
}
}
The program passes through this block of code without being able to execute it (as if the condition is always false).
Can anyone pinpoint my error in the aforementioned part of the code?