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: missing return statement }

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

    Default missing return statement }


    Newbie java question. I have the following simple program that is failing. Any assistance is appreciated!

    # javac CheckingAndSavingsOutputDemo.java
    CheckingAndSavingsOutputDemo.java:19: missing return statement
    1 error

    //first of two classes

    class Checking
    // field
    double balanceOfChecking = 0.0;

    // parameterized constructor
    Checking(double balanceOfChecking)
    // assign value of formal variable to field, weight refers to the field above
    this.balanceOfChecking = balanceOfChecking;

    // define a method
    double getBalance()
    System.out.println("My checking account has " + balanceOfChecking + ".");
    } <<<<<<<<<<<<<< failing here at line 19

  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    My Mood
    Thanked 263 Times in 232 Posts

    Default Re: missing return statement }

    Please see the Announcements page for the use of code tags
    When the method was declared, it was defined as returning a double. The body of the method prints but does not return a value.
    Search keywords: java method return value

Similar Threads

  1. Missing return statement???
    By Blinktwink in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 21st, 2013, 03:30 AM
  2. missing return statement need help!!
    By widowx in forum What's Wrong With My Code?
    Replies: 32
    Last Post: March 29th, 2013, 01:41 PM
  3. Missing return statement
    By beerye28 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 23rd, 2013, 06:48 PM
  4. Missing return statement
    By Stn in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 1st, 2011, 08:03 PM
  5. Prime number generator program missing return statement
    By 03EVOAWD in forum What's Wrong With My Code?
    Replies: 13
    Last Post: September 10th, 2009, 09:17 AM