Results 1 to 9 of 9
Like Tree1Likes
  • 1 Post By jbarke12

Thread: return 0?????

  1. #1
    faraa is offline Member
    Join Date
    Mar 2013
    Posts
    70
    Rep Power
    0

    Default return 0?????

    I have a very beginner question....
    Is there anything like "return 0" in cpp,in java?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default Re: return 0?????

    Yep, it returns 0 so it can only be a statement in a method that returns a number.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    faraa is offline Member
    Join Date
    Mar 2013
    Posts
    70
    Rep Power
    0

    Default Re: return 0?????

    Thank you so much.but if I use return 0 in a line that I want in cpp ,the program will finished in that line

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default Re: return 0?????

    The program won't be finished (neither in C++); it's the method/function that returns to its caller with zero as a return value.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    faraa is offline Member
    Join Date
    Mar 2013
    Posts
    70
    Rep Power
    0

    Default Re: return 0?????

    I didn't understand

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default Re: return 0?????

    Do you know what a return statement does? If not, first study the basics of the language because before that, answering any question will be useless.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    faraa is offline Member
    Join Date
    Mar 2013
    Posts
    70
    Rep Power
    0

    Default Re: return 0?????

    Yes,I know.
    But I thought return 0 is different of other return statements...
    Thank you again...

  8. #8
    jbarke12 is offline Member
    Join Date
    May 2013
    Location
    Charleston, South Carolina USA
    Posts
    82
    Rep Power
    0

    Default Re: return 0?????

    In C++ in the main method that does end the program. In Java a main method ends at the end of the method. return 0 in C++ in the main method is basically the same then as a return; in java.
    faraa likes this.

  9. #9
    faraa is offline Member
    Join Date
    Mar 2013
    Posts
    70
    Rep Power
    0

Similar Threads

  1. return
    By Sanna.1 in forum New To Java
    Replies: 1
    Last Post: 02-17-2012, 01:38 PM
  2. Using int/int, 7/5 would return 1
    By zoe in forum New To Java
    Replies: 2
    Last Post: 12-02-2008, 11:25 AM
  3. about 'return'.
    By helloworld in forum New To Java
    Replies: 9
    Last Post: 11-28-2008, 04:08 AM
  4. if..else..return
    By mqdias in forum New To Java
    Replies: 1
    Last Post: 08-10-2007, 04:20 PM

Posting Permissions

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