As shown below:
package com.lstc.test;public class TestDemo3 {String str = new String("hello");char[] ch = { 'a', 'b' };public static void main(String[] args) {TestDemo3 t = new TestDemo3();t.change(t.str, t.ch);//String is an encapsulated class, a value pass, and the char array is a reference pass System.out.println(t.str + " and " + t.ch[0] + t.ch[1]);}public void change(String str, char[] ch) {str = "test ok";ch[0] = 'c';}}The result is: str is hello, and the first element a of ch becomes c
The above is the full content of the implementation of String type delivery that the editor brings to you is value delivery, and the char[] type delivery is reference delivery. I hope it will be helpful to everyone and support Wulin.com more~