Java Programming Lesson 7 Part-3 | Scanner Input (more) – Advanced Usage
LESSON-7 PART-3
Scanner Input (more) – Advanced Usage
✅ Let’s continue Lesson-7 (Extended): Scanner Input – Advanced Usage
This will make you pro at taking inputs in Java 💪
📘 Scanner Input — Advanced Concepts
✅ Scanner is used to take input from keyboard
✅ Located in java.util package
Create Scanner object:
✅ Input Types
| Method | Input Type | Example |
|---|---|---|
nextInt() | Integer | 25 |
nextDouble() | Decimal number | 99.5 |
nextBoolean() | Boolean (true/false) | true |
next() | Single word string | "Java" |
nextLine() | Full line string | "Java Programming Course" |
nextFloat() | Float | 10.55f |
✅ Example 1: Taking Different Inputs
⚠️ Notice sc.nextLine() after nextInt()
This clears the buffer issue ✅
✅ Example 2: Taking Multiple Words Using nextLine()
✅ Example 3: Check Even or Odd
✅ Example 4: User Menu Input (Switch)
✅ Input Validation Example
🔥 BONUS — Password Input with Hidden Characters (Console)
(Works when running outside IDE like Eclipse terminal)
🧠 KEY POINTS
✔ nextLine() takes full sentence
✔ Use an extra nextLine() after numeric input
✔ Always close scanner → sc.close()
✔ Input validation using hasNextInt()
✅ Practice Task for You
Write a program to input:
-
Full Name
-
Mobile Number
-
Age
-
Course Name
Then print in a formatted way like:

No comments
Thank You For Visit My Website.
I Will Contact As Soon As Possible.