79800329

Date: 2025-10-26 21:48:28
Score: 1
Natty:
Report link

This is an old question, and I would just like to add an updated answer, in case someone finds it in a google search. So I would just Stream, Map, toArray.

Set<Integer> s = new HashSet<>();
int[] arr;
s.add(10);
s.add(20);
s.add(30);

arr = s.stream()
      .mapToInt(Integer::intValue)
      .toArray();
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Pream Totaram