有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

当我运行程序并输入输入时,结果是[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) 个答案

  1. # 1 楼答案

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

    试试这个:

    System.out.println(Arrays.toString(subset1white));
    
  2. # 2 楼答案

    您应该使用^{}方法,如下所示:

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

    一定要把

    import java.util.Arrays;
    

    在你们班上名列前茅。默认情况下,打印数组将使用^{}'s ^{} method,返回

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

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

    [abc, 123, def, 456]