Results 1 to 4 of 4
  1. #1
    BenH is offline Member
    Join Date
    Dec 2011
    Posts
    48
    Rep Power
    0

    Default What does the keyword 'return' do?

    I have many Java books. They mention the keyword 'return'. But, they do not explain what it does. What does this keyword do and accomplish? What is the point of using it? Thank you.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: What does the keyword 'return' do?

    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    MaxTheNorman is offline Member
    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Default Re: What does the keyword 'return' do?

    A return statement returns the information your have in-putted within your method etc... So, when the program is running, if it reaches a return statement then it will complete all the statements within the method.

  4. #4
    thinkinjava24 is offline Member
    Join Date
    Sep 2012
    Posts
    17
    Rep Power
    0

    Default Re: What does the keyword 'return' do?

    easily saying, if you make a method "void", no need to use return by the end of the method body, however, if you make a method, such as "int", "String", or "char", you have to assign a return value by the end of the method body, after the keyword "return". for example:

    int add(int i, int j) {
    return i+j;
    }

Similar Threads

  1. Same keyword #region in C#
    By hqt in forum New To Java
    Replies: 3
    Last Post: 01-27-2012, 11:21 AM
  2. Keyword : volatile
    By peiceonly in forum Advanced Java
    Replies: 13
    Last Post: 11-17-2010, 01:47 PM
  3. this keyword
    By coltragon in forum New To Java
    Replies: 10
    Last Post: 03-01-2010, 10:20 AM
  4. split Keyword
    By santhoshrao in forum New To Java
    Replies: 4
    Last Post: 08-13-2008, 11:28 AM
  5. Use of this keyword
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-18-2007, 08:32 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
  •