Pages

Oct 6, 2018

[HDGEM] How to convert Set to String[] in Java

Use the Set#toArray(T[]) method taking a typed array argument of the same size.

String[] myArray = myset.toArray(new String[myset.size()]);

A different size can also, but that would force the toArray() method to create a new array to return instead of reusing the provided argument, which may end up to be less efficient.

--
Posted By Blogger to HDGEM at 3/20/2017 08:50:00 AM

QuickBooks Self-Employed

Bigger tax refunds. Better organization. Manage your deductions with QuickBooks Self-Employed .