• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Handing a method it's own output

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

If I have (for instance) a method that takes an int and a String:
...what is the JAVA way of handing the output of the method back in to the method multiple times?

I figure I could nest it:

...but I'm not sure that that feels like the way it should be done.

Is there a "standard" way?

Full disclosure - I may just be trying to save myself from a nitpick here ;-)

Cheers,
Brian
 
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a gazillion (scientifically speaking) ways to skin a cat, but in general you'll probably do well with something like this:



The second one is confusing, has the potential for bugs, (and, pardon me for mentioning it) really ugly
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So to nitpick your snippet...



Please check the style guide for the correct naming of identifiers...

It could be written a little more succinctly (arbitrary values chosen instead of foo and bar).



 
Rian Nolan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...so I have saved myself a private nitpick by undergoing a public one?
Way to go - me.

Thanks for that Katrina - it DOES look and feel more readable.
Ever onward with Java-4b (Say)...
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, but it saved you an extra round trip on Say 4b... so it must have been worth it!
 
Rian Nolan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WELL worth it Katrina

Thanks a millon!
Brian
 
    Bookmark Topic Watch Topic
  • New Topic