有以下一个代码,运行中有显示输出的是地址(见注释),如果想打印数组的话,有什么好的方法吗?
见如下:
public class ArraysClass
{
public static void main(String[] args)
{
double[] list1 = {1.0,2.0,3.0,5.0,7.5,10.0,12.0,25.0};
double[] list2 = {1.0,2.0,3.0,5.0,7.5,9.0,11.0,23.0};
char[] chars = {'a','c','e','g','x','y','z'};
java.util.Arrays.sort(list1);
System.out.print(list1);//该处打印地址
java.util.Arrays.sort(chars,1,4);
System.out.println(chars);//该处不知显示什么
System.out.println(java.util.Arrays.binarySearch(list1,0,4,5.0));
System.out.println(java.util.Arrays.binarySearch(list2,4));
System.out.println(java.util.Arrays.binarySearch(chars,'e'));
System.out.println(java.util.Arrays.equals(list1,list2));
java.util.Arrays.binarySearch(list1,4);
System.out.println(list1);//该处显示地址
java.util.Arrays.binarySearch(list2,1,3,4);
System.out.println(list2);'//该处显示地址
}
} |