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

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -