Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: If Statement Help

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Thanked 0 Times in 0 Posts

    Post If Statement Help


    I currently have the following code written

    * Checks if ball is touching or beyound the left- or right-hand boundary of the shapes window
    public boolean isTouchingLeftOrRight()
    if (getBallXPos() <= 0 || getBallXPos() + 20 <= bottomEdge) {
    System.out.println ("true");
    } else {
    System.out.println ("false");

    however I receive a missing return statement. Any ideas on how to resolve?

    Missing return.jpg

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 698 Times in 680 Posts

    Default Re: If Statement Help

    Welcome! Please read this topic to learn how to post code in code or highlight tags and other useful info for newcomers.

    If you want to return a boolean from the method as currently specified, then return a boolean instead of printing true or false, as in replacing the println statements with:

    return true;


    return false;

    appropriately. If you don't want to return a boolean from the method, then change the method's return type from 'boolean' to 'void'.

  3. The Following User Says Thank You to GregBrannon For This Useful Post:

    jamesh (January 2nd, 2014)

Similar Threads

  1. Replies: 2
    Last Post: June 25th, 2013, 06:33 AM
  2. [SOLVED] A Loop statement and a switch statement issue
    By sternfox in forum Loops & Control Statements
    Replies: 13
    Last Post: March 7th, 2013, 04:19 PM
  3. Replacing an If statement with a Switch statement
    By logi in forum Loops & Control Statements
    Replies: 9
    Last Post: February 4th, 2013, 12:21 AM
  4. [SOLVED] If statement help
    By DarkPrince in forum Loops & Control Statements
    Replies: 1
    Last Post: November 7th, 2012, 04:15 PM
  5. If Statement
    By Shyamz1 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 26th, 2010, 12:57 PM

Tags for this Thread