aspose file tools*
The moose likes Beginning Java and the fly likes Return types and methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Return types and methods" Watch "Return types and methods" New topic

Return types and methods

Alix Ollivier
Ranch Hand

Joined: Jun 04, 2012
Posts: 71

Each time I want to move my character in the game I am building, I do code like this. and I write goLeft like this:

Is this correct, to call a return and have it call to itself? Or is there a way I can simply call goLeft without the accompanying coordinateX=? Coordinate X and Y are outside of the method.

"The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!', but 'That's funny...' "
- Isaac Asimov
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990

I wouldn't call it incorrect but I think a more elegant approach would be

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Paul Clapham

Joined: Oct 14, 2005
Posts: 18113

I would just do this:

It is sorta covered in the JavaRanch Style Guide.
subject: Return types and methods
Similar Threads
what this signature means?
My code should draw Julia set but instead it does not draw anything
regarding long and float
the code does not call paint method
convert scientific notation number format to normal number format