kucw.github.io icon indicating copy to clipboard operation
kucw.github.io copied to clipboard

Java - Pass by value or Pass by reference?

Open utterances-bot opened this issue 4 years ago • 1 comments

Java - Pass by value or Pass by reference?

介紹 Java 的參數傳遞到底是 pass by value 還是 pass by reference

https://kucw.github.io/blog/2018/9/java-pass-param/

utterances-bot avatar Jul 13 '21 07:07 utterances-bot

Java is always pass-by-value.

public static void fooIntList(List<Integer> intList) { IntStream.range(0, intList.size()).mapToObj(i -> intList.set(i, 2000)).collect(Collectors.toList()); }

:smiley:

113hyc avatar Jul 13 '21 07:07 113hyc