there are many posts on how to display the elements of LinkedList<String>, but I can't find something that I understand for LinkedList<String[]>.
The following code shows the output: LinkedList:[[Ljava.lang.String;@5305068a, [Ljava.lang.String;@1f32e575
whereas I'm looking for the output: LinkedList:[[Audi SQ5,341], [LandRover Discovery,306]].
and I don't want to overwrite the toString().
Code:
LinkedList<String[]> cars2 = new LinkedList<>();
String[] split_result = new String[2];
split_result = "Audi SQ5,341".split(",");
cars2.add(split_result);
split_result = "LandRover Discovery,306".split(",");
cars2.add(split_result);
// Displaying the size of the list
System.out.println("The size of the linked list is: " + cars2.size());
// Displaying the Strings in the linkedlist ??? (not their addresses)
System.out.println("LinkedList:" + cars2);
cars2.forEach(element -> System.out.println(element));
>` instead? Also its `toString()` method would generate more user-friendly result.
– Pshemo Dec 29 '20 at 18:06