Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Re: How to make an error message when my program crashes?

    In pseudo code:
    loop until good data type
    Ask user for data
    use hasNext to test if desired data type ready to be read
    if it is, exit the loop
    Use nextLiine() to read in the wrong data
    Tell user...
  2. Re: How to make an error message when my program crashes?

    Another approach is to use some of Scanner class's hasNext... methods. You can ask the Scanner object if the next thing in its buffer to be read is an int by using the hasNextInt() method. If what's...
  3. Re: How to make an error message when my program crashes?

    Another problem with using Scanner is that the invalid data is still in the buffer. The next nextInt() call will again try to make an int and will fail. You need to clear what is in the buffer...
Results 1 to 3 of 3