jeudi 16 avril 2020

If-else statement with String [closed]

import java.util.Scanner;
public class IfElse {

    public static void main(String[] args) {
        System.out.println("yes or no");
        Scanner scan = new Scanner(System.in);
        String respond = scan.nextLine();
        if (respond == "no")                    
            System.out.println("YOU DENIED");
        else if (respond == "true")
            System.out.println("YOU PROMISED");
    }
}

Can somebody help me? I just can't run it.

Aucun commentaire:

Enregistrer un commentaire