Introduction to Java (Part 2) - Take Input from User in Java

In the last post we learned how to write class, how to import packages, how to print output in java .Now by moving one step ahead , we will learn to take input from user in java.

✅ Take Input in Java -

You can take input from user using several ways . In this tutorial , we will learn to take input from user using Object of Scanner Class.

 For this we need to import java.util.Scanner package


After importing package , create an Object of Scanner Class. 

   

Now we can use Object of Scanner class i.e. sc to call methods predefined in Scanner Class to take input.

Have a Look on Different Methods for reading Different Input of Different Data-Types

Go through this example to understand how to use above methods to take input from user -


Output of the Code : 


Now you must able to take input from user and display the same on console.

If you have any queries, drop us mail 📧 or mention in comment section⮯

All the Best 👍👍👍

Happy Learning 😇😇😇


Post a Comment

Comments :

Previous Post Next Post