1 /*2 3 the value of the base data type is passed without changing the original value, because the stack is played after the call and the local variable disappears4 the value of the reference data type is passed, changing the original value, because even if the method is on the stack, but the heap memory array object is still in, you can continue to access through the address5 6 the value that the base data type passes to the parameter7 the address to which the reference data type is passed to the parameter8 9 But the address is also a value, so the argument is passed, and the pass is the value.Ten One */ A - - classdemo5{ the Public Static voidMain (string[] args) { - intA = 10; - intb =20; - +System.out.println ("A:" +a+ "B:" +b); - Change (A, b); +System.out.println ("A:" +a+ "B:" +b); A at int[] arr = {1,2,3,4,5}; -System.out.println (arr[1]); - - } - - Public Static voidChangeintAintb) { inSystem.out.println ("A:" +a+ "B:" +b); -A =b; tob = A +b; +System.out.println ("A:" +a+ "B:" +b); - } the * Public Static voidChangeint[] arr) { $ for(inti=0;i<arr.length;i++){Panax Notoginseng if(arr[x]%2==0){ -arr[x]*=2; the } + } A } the}
Java Language Foundation Study questions parameter passing problem in Java