Results 1 to 5 of 5
Like Tree2Likes
  • 1 Post By gozzy
  • 1 Post By Tolls

Thread: Understanding what exit on error means

  1. #1
    jok7er is offline Member
    Join Date
    Feb 2017
    Posts
    4
    Rep Power
    0

    Default Understanding what exit on error means

    When given instructions for creating a program, the phrase
    Report bad input via IO.reportBadInput() and exit on error.
    What does this mean? Is an error different from a bad input and if so, how are they different and what is an example?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Understanding what exit on error means

    error is sort of a generic word that can be used to cover many things. If a user enters bad input, that could be considered an error on his part.
    Wrong syntax in a program is an error. Many exceptions in a program are considered errors. There is a java class named Error with the text: An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Understanding what exit on error means

    Errors are usually something that you cannot recover from (stack overflows, out of memory errors). Checked exceptions are things that you can possibly recover from (which is why they are checked). And there is nothing to prevent you from catching an exception and throwing an error in its place. It depends on the circumstances.

    And then there are assertions. If they are enabled, they can indicate internal errors beyond the control of the user. In other words, a bug in the program.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    gozzy is offline Member
    Join Date
    Jan 2017
    Posts
    46
    Rep Power
    0

    Default Re: Understanding what exit on error means

    Use the named method and then do:

    Java Code:
    System.exit(1);
    That's probably what they mean
    quad64bit likes this.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Understanding what exit on error means

    Yep.
    That reads like a C description, where exiting on error means returning a non-zero number.
    So the equivalent for Java is as gozzy suggests.
    quad64bit likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 4
    Last Post: 10-10-2014, 02:03 PM
  2. What the error means?
    By MaXER in forum New To Java
    Replies: 12
    Last Post: 09-17-2012, 02:09 PM
  3. Replies: 1
    Last Post: 04-17-2012, 01:03 AM
  4. what does this error means?
    By tiiim83 in forum New To Java
    Replies: 2
    Last Post: 01-06-2009, 03:17 PM
  5. Does anyone know what these error means?
    By minifish in forum New To Java
    Replies: 2
    Last Post: 11-04-2008, 04:37 AM

Posting Permissions

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