How to pass varargs by reference in Java

前端 未结 6 1224
青春惊慌失措
青春惊慌失措 2021-01-29 03:53

I\'m writing a method that receives any number of arguments and returns them modified. I have tried with varargs but it doesn\'t work, here you can see a simplified version of t

6条回答
  •  旧巷少年郎
    2021-01-29 04:38

    You can not.Java only does call-by-value. See How to do call by reference in Java? and Is Java "pass-by-reference" or "pass-by-value"?

    You could return an Array of strings with the new strings and use this

提交回复
热议问题