[Ljava.lang.String; @ 5d79a22d结果

时间:2014-03-14 15:29:08

标签: java

当我运行程序并输入输入时,结果为[Ljava.lang.String;@5d79a22d 我不确定这意味着什么或为什么会发生这种情况。 这是我的计划的一部分:

Scanner s = new Scanner(System.in);
//first input
System.out.println("Enter your first input: ");
String first = s.nextLine();
String[] firstsplit = first.split(", ");
//second input
System.out.println("Enter your second input: ");
String second = s.nextLine();
String[] secondsplit = second.split(", ");
//third input
System.out.println("Enter your third input: ");
String third = s.nextLine();
String[] thirdsplit = third.split(", ");
//fourth input
System.out.println("Enter your fourth input: ");
String fourth = s.nextLine();
String[] fourthsplit = fourth.split(", ");
//fifth input
System.out.println("Enter your fifth input: ");
String fifth = s.nextLine();
String[] fifthsplit = fifth.split(", ");
//declares array of numbers for whites with given numbers

String[] subset1white= Arrays.copyOfRange(firstsplit, 1, Integer.parseInt(firstsplit[0]));
System.out.println(subset1white);

任何帮助都将不胜感激。

2 个答案:

答案 0 :(得分:2)

这是因为您正在调用常规数组的toString方法

试试这个:

System.out.println(Arrays.toString(subset1white));

答案 1 :(得分:0)

您应该使用Arrays.toString(Object[])方法,如下所示:

System.out.println(Arrays.toSting(subset1white));

确保放

import java.util.Arrays;

在班级的顶部。默认情况下,打印数组将使用Object's toString() method,返回

getClass().getName() + '@' + Integer.toHexString(hashCode())

Arrays.toString(Object[])将返回如下字符串:

[abc, 123, def, 456]