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: Need help with a "missing return statement"

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Thanked 0 Times in 0 Posts

    Default Need help with a "missing return statement"

    Maybe I'm missing something, but the return is right there, plain as day...

    This is the typical bank account program when learning about classes.

    package lab03;
    public class Account 
        public double balance;
        public Account(double amount)
            balance = amount;
        public Account()
            balance = 0.0;
        public void deposit(double amount)
            balance += amount;
        public double withdraw(double amount) 
            if (balance >= amount) 
                //it says there's a missing return statement, but it's right here
                return balance -= amount;
                System.out.println("Insufficient funds");
        public double getBalance() 
            return balance;
    Last edited by guppy507; October 13th, 2011 at 05:45 PM.

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 636 Times in 540 Posts

    Default Re: Need help with a "missing return statement"

    What happens if balance is less than amount?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. using if statement on string System.getProperty("os.name") not working
    By sauyon in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 29th, 2011, 12:09 PM
  2. Missing return statement
    By mrroberts2u in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 10th, 2011, 06:11 AM
  3. first itteration of "for" statement acts differntly to all the rest, why?
    By SPACE MONKEY in forum Java Theory & Questions
    Replies: 4
    Last Post: March 1st, 2011, 11:06 AM
  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. Error of "Class has no return statement"
    By mdstrauss in forum What's Wrong With My Code?
    Replies: 7
    Last Post: August 2nd, 2009, 12:00 PM