Results 1 to 2 of 2

Thread: JAVA - how to check if user input is not an int value

  1. #1
    Join Date
    Jul 2013
    Beans
    8

    JAVA - how to check if user input is not an int value

    I'm trying to figure out how to check if user input is not an int value
    Code:
    Solved it
    

    Line 25 is the first two line in that bit of code
    Last edited by 7nQecEL; August 13th, 2013 at 03:56 AM.

  2. #2
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: JAVA - how to check if user input is not an int value

    You need to check hasNextInt() before you attempt to use nextInt() on line 25.

    HINT: You can use next() to skip to the next input token.

    Are scan and sc both instances of Scanner? Or did you just mistype?
    Please create new threads for new questions.
    Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •