I want to display the contents of an array of linked lists. Each linked list contains a String array. The content of the array of linked lists is displaying as [[[Ljava.lang.String;@15db9742], [[Ljava.lang.String;@6d06d69c], [[Ljava.lang.String;@7852e922]]. How do I solve this?
public class LinkedListOfStringArrays {
public static void main(String[] args) {
LinkedList<String[]> Values[] = new LinkedList[3];
for (int i = 0; i < 3; i++){
Values[i] = new LinkedList<String[]>();
}
String[] first = {"first element", "ABC"};
String[] second = {"second element", "DEF"};
String[] third = {"third element", "GHI"};
Values[0].add(first);
Values[1].add(second);
Values[2].add(third);
System.out.println(Arrays.toString(Values));
}
}
Arrays.toStringprobably, another option (prefered) would be to use a custom class (with proper toString) for the pair of strings and not an arrayLinkedList<String[]> Values[]?? This creates an array of linked lists... Why do you want this?