Check out example codes for "convert hashset to array". It will help you in understanding the concepts better.

Code Example 1

//	First of all, you shouldn't use raw types.
//	Use :
	Set<Integer> set = new HashSet<>();
//	Then convert to array :
	Integer[] arr = x.toArray(new Integer[set.size()]);
//	Using x.toArray() would give you an Object[].

Learn ReactJs, React Native from