+ 1

How to get input in java

I can’t figure out how to get user input in java. would you please help?

9th Jan 2018, 12:31 AM
Campbell
Campbell - avatar
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 } }
9th Jan 2018, 1:02 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
import java.util.*; Scanner input= new Scanner (System.in); int n = input.nextInt();
9th Jan 2018, 12:37 AM
Hrishikesh Kulkarni
Hrishikesh Kulkarni - avatar