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 8836393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:29:01+00:00 2026-06-14T09:29:01+00:00

I am curious as to what the error java.util.InputMismatchException means and why I am

  • 0

I am curious as to what the error java.util.InputMismatchException means and why I am getting it. This program is the driver class for a file called Dog.java that takes a dog’s info and stores it as a string. This file is what directly takes the info and later prints the information out.

The data I am putting in is:

Disco Bandito  
4  
Sally Struthers  
5  
Moosen  
87  

Here is my Code:

import java.util.Scanner;

public class Kennel {

    public static void main(String[] args) {

    String value1 = null;
    int value2 = 0;
    String value3 = null;
    int value4 = 0;
    String value5 = null;
    int value6 = 0;

        //takes the input from a text file

    Scanner scanner = new Scanner(System.in);

        while (scanner.hasNextLine()){

        value1 = scanner.nextLine();
        value2 = scanner.nextInt();
        value3 = scanner.nextLine();
        value4 = scanner.nextInt();
        value5 = scanner.nextLine();
        value6 = scanner.nextInt();
    }

        //the three "dogs" in a kennel

    Dog Dog1 = new Dog();

    Dog1.setName(value1);
    Dog1.getName();
    Dog1.setAge(value2);
    Dog1.getAge();
    Dog1.toString();

    Dog Dog2 = new Dog();

    Dog2.setName(value3);
    Dog2.getName();
    Dog2.setAge(value4);
    Dog2.getAge();
    Dog2.toString();

    Dog Dog3 = new Dog();

    Dog3.setName(value5);
    Dog3.getName();
    Dog3.setAge(value6);
    Dog3.getAge();
    Dog3.toString();

    System.out.println(Dog1.toString());
    System.out.println(Dog2.toString());
    System.out.println(Dog3.toString());

    }
}

Thanks,
Jake

  • 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-14T09:29:02+00:00Added an answer on June 14, 2026 at 9:29 am

    From the docs for InputMismatchException:

    Thrown by a Scanner to indicate that the token retrieved does not match the pattern for the expected type, or that the token is out of range for the expected type.

    That pretty much says all that needs to be said. Check your file for unexpected input.

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

Sidebar

Related Questions

I am really curious about this question. When we compile .java file using javac
I found a workaround for this error, but am now really curious as to
Curious what "Toast" means? Saw this and am curious... Similar Posts How to add
I am having a curious problem. I had this Java application which was previously
I was curious why I would be getting a SIGABRT error when I am
I'm curious what is the 'proper' pythonic way of handling this error with a
I'm curious, how come I get 404 error running this line: urllib2.urlopen(http://localhost/new-post#comment-29) While everything
I'm curious to know why the C# compiler only gives me an error message
The compiler doesn't give me any error and the code runs. Just curious how
Curious, what happens when you return keyword this from a struct in C#? For

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.