This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Basic doubt - How to create methods in Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Basic doubt - How to create methods in Java?" Watch "Basic doubt - How to create methods in Java?" New topic

Basic doubt - How to create methods in Java?

André Asantos
Ranch Hand

Joined: Nov 23, 2009
Posts: 234
void takeMoney(double value){
totalMoney = totalMoney - value;

Why is there attribute into curly braces? I already saw the Object class...
marc weber

Joined: Aug 31, 2004
Posts: 11343

"totalMoney" is a variable defined outside of this method, and this method is just reducing the value of "totalMoney" by the amount of "value" (the method's parameter).

Does that answer your question? I'm not sure I understand what you're asking.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
1) void is the return type of the method

2) takeMoney is the method name

3) value is the method argument of type double

4) Inside the two curly braces lives the method body

Take a look at this

Have you checked out Aspose?
subject: Basic doubt - How to create methods in Java?
jQuery in Action, 3rd edition