+ 1
How to make user input comparasion in Java
import java.util.scanner; public class test{ public static void main(String[]args){ Scanner a = new Scanner(System.in); if(a.int()>1){ System.out.println("hai"); } } } /* https://code.sololearn.com/cpvWvJOScf62/?ref=app this is a simple example, can someone help */
2 odpowiedzi
+ 10
Use nextInt() method of Scanner class to read integer input from user. For example:
Scanner a = new Scanner(System.in);
int n = a.nextInt();
if(n>1){
System.out.println("hai");
}
+ 2
import java.util.Scanner;
public class Program{
public static void main(String[] args) {
Scanner a = new Scanner(System.in);
int input_0 = a.nextInt();
if(input_0 > 5){
System.out.println("hai");
}else{
System.out.println("no hai");
}
}
}