提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将一个数组引用分配给另一个数组:共享公共元素
public class Main { public static void main(String[] args) { /** nowjava.com - 时 代 Java **/ int[] v = { 0, 1, 2, 3, 4 }; System.out.println("Reference of array u in memory:" + v); System.out.println("Value of the 3rd element of array v:" + v[2]); // Declare a new array and assign its reference to the reference of array v int[] t = v; System.out.println("Reference of array v in memory:" + v);// same as u System.out.println(v[2]);