String[] and Object[]

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • blizzard

    String[] and Object[]

    Hi to all.
    I have an object 'o1' whose constructor is

    o1(String[] arrayOfStrings)
    {
    ...
    }

    and an ArrayList 'list' of object String:

    list.add("Eleme nt of list");

    How can I pass the strings of 'list' to the object 'o1'?
    I don't know how to use the toArray method of ArrayList, because

    new o1(list.toArray ());

    returns an array of object (Object[]) and 'o1' doesn't like it.
    Is there a way to convert Object[] into String[]?
    Can you help me?


  • blizzard

    #2
    Re: String[] and Object[]

    Never mind, I found it.
    Just

    o1((String[])list);


    Comment

    Working...