FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Scanner Class
How-ToProgramming Languages

Scanner Class

via Dev.to BeginnersIndumathy12h ago

Class in Java Definition The Scanner class is a predefined class in Java used to take input from the user. It belongs to: java.util package Why Scanner? It is used to read: int double float String boolean long etc. How to Use Scanner Step 1: Import the package import java.util.Scanner; Step 2: Create Scanner Object Scanner sc = new Scanner(System.in); ✔ System.in → Takes input from keyboard ✔ sc → Object name Step 3: Take Input int age = sc.nextInt(); String name = sc.nextLine(); double salary = sc.nextDouble(); Important Concept (Very Important 🔥) If you write: int age = sc.nextInt(); String name = sc.nextLine(); The nextLine() may get skipped because nextInt() does not consume the newline. ✔ Correct way: int age = sc.nextInt(); sc.nextLine(); // consume leftover newline String name = sc.nextLine(); Common Scanner Methods nextInt()-Integer nextDouble() - Decimal number next() - Single word nextLine() - Full sentence nextBoolean() - true/false Always Close Scanner Java Copy code sc.clo

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
0 views

Related Articles

The Quiet Advantage of Learning in Small, Practical Steps
How-To

The Quiet Advantage of Learning in Small, Practical Steps

Medium Programming • 2h ago

2. Readers-writers Problem
How-To

2. Readers-writers Problem

Medium Programming • 5h ago

The Part Nobody Could Scale
How-To

The Part Nobody Could Scale

Medium Programming • 6h ago

Claude Code Now Lets You Code From Your Phone. Here’s What I Learned the Hard Way.
How-To

Claude Code Now Lets You Code From Your Phone. Here’s What I Learned the Hard Way.

Medium Programming • 6h ago

Stop Watching Tutorials: The Real Way to Learn Coding Faster
How-To

Stop Watching Tutorials: The Real Way to Learn Coding Faster

Medium Programming • 7h ago

Discover More Articles