Thursday 28 July 2016

java - [Ljava.lang.String;@5d79a22d result





When I run my program and type in the inputs the result is [Ljava.lang.String;@5d79a22d
I'm not sure what this means or why it is happening.
This is part of my program:



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);



Any help would be appreciated.


Answer



This because you're calling toString method of a regular array



Try this:



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

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...