Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8897709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:24:58+00:00 2026-06-15T00:24:58+00:00

So this question is kinda simple, but I was wondering why the following code,

  • 0

So this question is kinda simple, but I was wondering why the following code, after running perfectly the first time, jumps straight to “Enter the page number: “, instead of asking for the title the second loop around. I’ve read somewhere that there is something up with Java that won’t allow for a reuse of a Scanner. Is this the problem that I’m facing? I’ve tried to use kbReader.next() and that works, but the code only works with strings without spaces.

String title = "";
int page = 0;
int i = 0;
Scanner kbReader = new Scanner(System.in);

for (i=1;i<=3;i++){
        System.out.print("Enter the title: ");
        title = kbReader.nextLine();
        System.out.print("Enter the page number: ");
        page = kbReader.nextInt();

        System.out.print(title);
        System.out.println(page);
    }

Much help appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:25:00+00:00Added an answer on June 15, 2026 at 12:25 am

    You should add a kbReader.nextLine(); after kbReader.nextInt();. On the second loop, your kbReader.nextInt(); is just reading the end-of-line in the stream, left out by kbReader.nextInt();.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is kinda simple (don't be so harsh with me), but I can't
I know this is a really simple question, but I was just wondering if
This question is kinda aimed towards PHP but it probably applies to other languages
Kinda of embarrassing to ask this question after few years working with Hibernate... I
I originally started this question in another thread, but that thread was sorta, kinda
This is kinda....a two part question. The first one is much more important than
I apologize up front for the broadness of this question, but I'm wondering if
my question is kinda simple but i just don't know how to get it.
Hello yeah I'm asking this question a second time, sorry about that but I
the answer for this question is probably simple but currently I'm stumped and any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.