How do I convert List<List<Object>> to a multi-dimensional array?

user3778684
List<List<Object>> EventAll = new ArrayList<List<Object>>();

while(rs1.next())
{
    List<Object> row = new ArrayList<Object>();
    /*EventAll.add(rs1.getRow(), row);*/
    row.add(rs1.getString("eventName")); 
    row.add(rs1.getString("duration")); 
    row.add(rs1.getString("playhead"));
    EventAll.add(row);
}

String[][] stringArray = EventAll.toArray(new String[EventAll.size()][]);//line 66

In the above example as you can see I have List<List<Object>> and I am adding column values to it in the while loop. It worked fine for me at this point.

But when I tried converting it into multi-dimensional array using toArray() method I am getting the following exception:

****EXCEPTION:**java.lang.ArrayStoreException
    at java.lang.System.arraycopy(Native Method)
    at java.util.ArrayList.toArray(Unknown Source)
    at DataFromMySql.main(DataFromMySql.java:66)**
SatyaTNV
Object[][] array = new Object[EventAll.size()][];

int i = 0;
for (List<Object> event : EventAll) {//each list
    array[i++] = event.toArray(new Object[event.size()]);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do i convert a json array object of an object into a java 8 optional list of that object

How do I convert java.sql.Array to List<MyCustomEnum>?

How do I convert a tuple of tuples to a one-dimensional list using list comprehension?

How do I convert an object array to an object list

How do I convert an array of arrays into a multi-dimensional array in Python?

how do I convert an object to an array list in JS

How do you convert a List of object to a one dimensional array?

how do i correctly handle a multi dimensional numpy array

How can I reshape this multi-dimensional list to a 2D array?

How do i convert List into datetime.date object?

How do I convert a Json file (that contains a array) to a List (of a class object) C# Unity

How do I return such an multi-dimensional array?

How do I find maximum value in a multi dimensional array

How to convert List of arrays to two dimensional array?

Convert object to multi-dimensional array - JavaScript

How do I get values inside this multi-dimensional array

How do I trim '\n' in multi dimensional array in php

How do I convert Pandas object to a list in python3

How can I convert this list of pairs into an object that contains an array of arrays?

How do return the duplicates in a multi two dimensional list?

Error 'int' object is not subscriptable, How do i convert it to list?

How do I return such an multi-dimensional array

How do I convert an array or a list into a hashref?

How do I convert an array object into a two-dimensional array

How to convert custom class list to two dimensional array

How would I convert a dictionary into a multi-dimensional list sorted by value?

How do I convert a list into a dictionary grouped by object name?

How to transform a multi dimensional array from a CSV file into a list

How to match 2 two multi-dimensional list or array

TOP Ranking

  1. 1

    How to return a single asset OhMyBrew Laravel Shopify

  2. 2

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    pump.io port in URL

  6. 6

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  7. 7

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  8. 8

    Make a B+ Tree concurrent thread safe

  9. 9

    Group boxplot data while keeping their individual X axis labels in ggplot2 in R

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  12. 12

    BigQuery - concatenate ignoring NULL

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  15. 15

    Razor Page - How to redirect to another folder's page using asp-for tag helper

  16. 16

    "django.db.utils.ProgrammingError: relation "auth_user" does not exist" Django V2.0

  17. 17

    How to exclude a specific git submodule from update?

  18. 18

    how to fix CMake Error in CMakeLists.txt: Generator NMake Makefiles does not support platform specification, but platform x64 was specified

  19. 19

    Is there a way to ask the user before loading the website

  20. 20

    How to remove the extra space from right in a webview?

  21. 21

    Optimising manipulation of large vectors

HotTag

Archive