Passing params in java by reference -
this question has answer here:
- is java “pass-by-reference” or “pass-by-value”? 71 answers
- how return multiple objects java method? 24 answers
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
Post a Comment