#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    How to create an array of maps


    Hi,
    I would like to use simpleJdbcInsert class and executeBatch method

    public int[] executeBatch(Map<String,Object>[] batch)

    So I need to pass an array of Map<String,Object> as paramter. How to create such an array?
    What I tried is
    Map<String, Object>[] myArray = new HashMap<String, Object>[10]

    It is error: Cannot create generic array of Map<String, Object>

    So how to create an array of Map<String, Object> ?
    Thanks
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by lalossa
    Hi,
    I would like to use simpleJdbcInsert class and executeBatch method

    public int[] executeBatch(Map<String,Object>[] batch)

    So I need to pass an array of Map<String,Object> as paramter. How to create such an array?
    What I tried is
    Map<String, Object>[] myArray = new HashMap<String, Object>[10]

    It is error: Cannot create generic array of Map<String, Object>

    So how to create an array of Map<String, Object> ?
    Thanks
    You could make an ArrayList from this using the List interface.

    Code:
    List<HashMap<String, Object>> l = new ArrayList<HashMap<String,Object>>();
    Greetings, Jojo

IMN logo majestic logo threadwatch logo seochat tools logo