+ 1
How to get input in java
I canât figure out how to get user input in java. would you please help?
2 Answers
+ 28
import java.util.Scanner; //importing scanner class
public class Program {
public static void main(String []args){
Scanner sc=new Scanner (System.in); //object sc of Scanner class
int n=sc.nextInt ();
String name=sc.nextLine;
double d=sc.nextDouble ();
//and many more methods ... u will find list in the lesson
}
}
+ 3
import java.util.*;
Scanner input= new Scanner (System.in);
int n = input.nextInt();