aspose file tools*
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
Author

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
Sheriff

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
sscce.org
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


Bye,
Nicola
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Basic doubt - How to create methods in Java?