java数组元素的输出

java数组元素的输出

利用Arrays.toString(数组名即可)

String[] name = {"Tom", "John", "Nike"};
System.out.println(name);                    //1
System.out.println(Arrays.toString(name));   //2

输出结果为:

  语句2:@489... (显然是一个地址,即数组地址,并不是数组内容)

  语句2:Tom, John, Nike

原文地址:https://www.cnblogs.com/silentteen/p/6079048.html