Results 1 to 6 of 6
  1. #1
    devstarter is offline Member
    Join Date
    Mar 2010
    Posts
    6
    Rep Power
    0

    Default Boolean Return Value

    [code]
    Java Code:
    public boolean isFull(){  //generally full
        	if(parcelIsFull() || hcparcelIsFull() || noSharingParcel())
        		return true;
        }
    I want to know why i get this error [code]

    Java Code:
    missing return statement
    I have the value written as 'true' boolean as the returning value.

  2. #2
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    305
    Rep Power
    6

    Default

    What happens if the if-statement fails? Would anything be returned?

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

    Default

    Crossposted here and here and here.

    kind regards,

    Jos

  4. #4
    djr1 is offline Member
    Join Date
    Feb 2010
    Posts
    5
    Rep Power
    0

    Default

    Java Code:
    if()
      return true;
    else
      return false;

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

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

    Default

    Quote Originally Posted by djr1 View Post
    Java Code:
    if()
      return true;
    else
      return false;
    Instead of doing this:

    Java Code:
    if(<boolean_expression>)
      return true;
    else
      return false;
    ... better do this:

    Java Code:
    return <boolean_expression>;
    kind regards,

    Jos

Similar Threads

  1. Boolean value not working?
    By zerkz in forum New To Java
    Replies: 3
    Last Post: 09-29-2009, 06:42 AM
  2. transfer boolean to 1's and 0's
    By Nikohw in forum Java Applets
    Replies: 5
    Last Post: 09-12-2009, 09:05 PM
  3. 1 as an integer, not boolean
    By McChill in forum New To Java
    Replies: 1
    Last Post: 05-02-2009, 09:39 PM
  4. Simple Boolean
    By jigglywiggly in forum New To Java
    Replies: 3
    Last Post: 01-01-2009, 05:01 AM
  5. boolean variables
    By ravian in forum New To Java
    Replies: 3
    Last Post: 12-31-2007, 04:58 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
  •