Value-Returning Method r We call a method that returns a value a value returning method or non-void method. A value-returning method must include a return statement in the following format return <expression> i public double toDollar( double foreignMoney return ( foreignMoney exchangeRate)i C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 4-11
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 4 - 11 Value-Returning Method We call a method that returns a value a valuereturning method , or non-void method. A value-returning method must include a return statement in the following format: return <expression> ; public double toDollar( double foreignMoney ) { return (foreignMoney / exchangeRate); }
Method Header comment in javadoc Converts a given amount in dollars into an equivalent amount in a foreign currency x @param dollar the amount in dollars to be converted Return amount in foreign currency C 2000 McGraw-Hill troduction to Object-Oriented Programming with Java--Wu Chapter 4-12
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 4 - 12 Method Header Comment in javadoc /** * Converts a given amount in dollars into * an equivalent amount in a foreign currency. * * @param dollar the amount in dollars to be converted * * @return amount in foreign currency */