public class Test1 { public static void main(String[] args) { String s1 = "hello"; int mas[] = new int[3]; test(mas); test2(s1); System.out.println(mas[0]); System.out.println(s1); } static void test(int massive[]) { massive[0] = 1; } static void test2(String string) { string.concat("111"); } } In both cases, for reference types, a copy of the object reference is passed. But only in the case of an array, we change this object. And in the case of a string instead of a variable, a new object is not created (I remember that the string itself cannot be changed).
Why? What don't I understand?
String.concatdoes not change anything, it returns a new line - vp_arth