How to convert Vector to String array in java

后端 未结 7 1638
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 17:58

How to convert Vector with string to String array in java?

7条回答
  •  生来不讨喜
    2021-01-01 18:57

    Try this:

    vector.toArray(new String[0]);
    

    Edit: I just tried it out, new String[vector.size()] is slower then new String[0]. So ignore what i said before about vector.size(). String[0] is also shorter to write anyway.

提交回复
热议问题