How to convert an ArrayList containing Integers to primitive int array?

前端 未结 18 1603
情书的邮戳
情书的邮戳 2020-11-22 11:23

I\'m trying to convert an ArrayList containing Integer objects to primitive int[] with the following piece of code, but it is throwing compile time error. Is it possible to

18条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 11:36

    It bewilders me that we encourage one-off custom methods whenever a perfectly good, well used library like Apache Commons has solved the problem already. Though the solution is trivial if not absurd, it is irresponsible to encourage such a behavior due to long term maintenance and accessibility.

    Just go with Apache Commons

提交回复
热议问题