0

I have the list of Arrays of Objects and storing in to the List

Object[] data = [12.0, 0.05, 100.0, 3.0, 5.0, a, cat, 3];

List<Object[]> events = new ArrayList<Object[]>();

events.add(data);

System.out.println(events.toString());

When I am printing I am getting in this format [[Ljava.lang.Object;@23e028a9] , I tried .toString() and other but neither worked.

Please help me to solve this problem to see the correct form in output.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • 1
    You are trying to print the List, you should print the list's contents instead. – Stultuske Aug 30 '16 at 06:51
  • Well basically, calling `toString()` on an `Object[]` *is* going to come up with that. If you want prettier output, I'd suggest creating a list of elements where each element can print more usefully. – Jon Skeet Aug 30 '16 at 06:52
  • iterate over the List, and print the iterated element. Using an enhanced for loop seems easiest – Stultuske Aug 30 '16 at 06:55
  • for (Object[] event : events) { System.out.println(event.toString()); } Like this ? –  Aug 30 '16 at 06:59
  • @Stultuske can't I print and see the whole list without going each ? –  Aug 30 '16 at 07:57

0 Answers0