Passing params in java by reference -


i'm new comer form c#, , know "java pass-by-value."

but pass-by-reference useful when want multiple outputs 1 method.

how can multiple outputs 1 method in java, in c#.

i know 1 way -- use generic wrapper class, , value field.

class wrapper<t> {     public wrapper(t value) {         value = value;     }     public t value; } 

is there way realize effect?

no, java not have out parameters. can pass object reference method modify pretend has out parameters, isn't best design , runs other issues (multithreading , mutable state one).

the best way achieve method returns multiple values have method return type contains multiple values.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -