public class Dog {public void Age (int. int age) {///Copy new ageage++;//to copy modified System.out.println (age),} public void Arrdemo (int[] ar R) {Arr[2] = 100;//Modify the data in the heap for (int i =0;i<arr.length;i++) {System.out.println (arr[i]+ "");}} public static void Main (string[] args) {//TODO auto-generated method Stubdog dog = new Dog (); int = 10;//Pass basic data type, new in stack Space to copy a copy of age. The modified age is a copy and does not modify the value of age in the main function stack of dog. Age (age); System.out.println ("main" +age); int[] arr = {1,2,3,4,5};//modifies the reference data type, modifies the data in the heap, and arr in the main function stack and the copy is a pointer to the same data field in the heap, and the copy is changed. The number in the main function also changes to Dog.arrdemo (arr); for (int i =0;i<arr.length;i++) {System.out.println (arr[i]+ "");}}
The Java method modifies the difference between the basic data type and the reference data type in the main function