mercredi 1 novembre 2017

Scanner and if/else class (converting int to boolean)

the below is my code. Where it says passcode = true, it's throwing an error. I'm a complete noob to Java so I'm not sure what to do?

package test; import java.util.Scanner;

public class test {

public static void main (String[] args) 
{

int passcode = 12345;

Scanner input = new Scanner (System.in);

    System.out.println("Please enter in the passcode: ");
    int passcodeEntry = input.nextInt();

    if (passcode = true) { 
        System.out.println(passcodeEntry + " Is the correct passcode!");

        } else { 

        System.out.println("This is the wrong passcode, please try again");


    }


}

}

Aucun commentaire:

Enregistrer un commentaire