mardi 10 mars 2020

Java If Statement having multiple conditions with && operator not working [duplicate]

private void validate(String userName, String userPassword){
        if((userName == "Admin") && (userPassword == "1234")){
            Intent intent = new Intent(MainActivity.this, SecondActivity.class);
            startActivity(intent);
        } else{
            counter --;
            Info.setText(userName + " Number of Attempts Left: "+String.valueOf(counter) + " - " + userPassword);
            if(counter == 0){
                Login.setEnabled(false);
            }
        }
    }

Whenever i give input as "Admin" and "1234" condition goes to else part. please help me i am beginner in this field.

Aucun commentaire:

Enregistrer un commentaire