I have the following code
package Condicionales;
import java.util.Scanner;
public class PruebaJava {
public static void main(String[] args) {
/*float numero1;
float numero2;
float total;
*/Scanner lector = new Scanner(System.in);/*
System.out.println("Ingrese un valor numerico");
System.out.println("RECUERDA QUE PARA USAR DECIMALES USA ','");
numero1 = lector.nextFloat();
System.out.println("Ingrese un valor numerico X2");
numero2 = lector.nextFloat();*/
System.out.println("Escoja el tipo de operacion a realizar");
System.out.println("1. Suma");
System.out.println("2. Resta");
System.out.println("3. Multiplicacion");
System.out.println("4. Division");
System.out.println("Escriba el numero o tipo de operacion");
String tipoOperacion = lector.next();
if (tipoOperacion == "Suma" || tipoOperacion == "suma") {
System.out.println("Suma!!");
}
System.out.println("... " + tipoOperacion);
}
}
In the if part, if I enter "Sum" the condition is not fulfilled, I thought that possibly in the variable typeOperacion something else was being saved, but no, it is exactly "Sum" and the if does not return true
Keep in mind that if I add the value to the variable from the code, it works correctly, but when the user is allowed to enter the value, the if does not return true.