0
For some reason, when I type in the answer, nothing happens, anyone who can help me to fix it, I thank you
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String resposta;
System.out.println("Quanto é 2 + 2?");
resposta = in.nextLine();
if(resposta == "4")
System.out.println("Resposta correta!");
}
}
string must be compared with equals,
if("4".equals(resposta))
should already work– Henrique Lemes Baron