google.com, pub-8786015629279405, DIRECT, f08c47fec0942fa0 Input Statement in Java Using SCANNER Class

Input Statement in Java Using SCANNER Class

0
Input Statement in Java Using SCANNER Class
Input Statement in Java Using SCANNER Class



Java Language Provides many ways to input a data using keyboard on the run time of a program. Scanner class is one and the one of the best way for user input.

Scanner class found under the Java package java.util.Scanner. So we can import this package with the program and use this class.

 import java.util.*;

 

// this package holds the all the feature / function of Scanner class.

 

public class scan

{

      public static void main (String args[])

      

       {

              Scanner sc=new Scanner (System.in);

              System.out.printil("Enter Your City Name ");

              String Name=sc.nextLine();

              System.out.println("City Name is : " +Name);

         }

}

Output

 

Enter Your City Name Bulandshahr

City Name is : Bulandshahr

 

In the Above Program, First Line will import the java.util package which can be use to access the Scanner Class

Scanner Class provide a number of method to input a Data from the user. By default System provide a String value which we convert as per the required Data or Value for Integer we use nextInt() and so on.

There is a List of Method of Scanner class on the basis of Data types...

ER.Ashish Goel

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Thank you for your interest 😊

We will back shortly after reviewing...

Thank you for your interest 😊

We will back shortly after reviewing...

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top