How does one do an if statement withuser input? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How does one do an if statement withuser input?

I'm trying to make a password program, but ai just cant seem to get iy right...

27th Aug 2016, 2:56 PM
Adam Lang
Adam Lang - avatar
1 Answer
+ 1
import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); int x= myVar.nextLine(); if(x==1234){ System.out.println("pass is true"); } else{ System.out.println("pass is false"); } } }
27th Aug 2016, 4:30 PM
mehdi