It's not a secret anymore!
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
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: 10768

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: 19875

I would just do this:

I agree. Here's the link:
subject: Return types and methods
It's not a secret anymore!