convert hashset to int array java
import java.util.Arrays;
import java.util.Set;
import java.util.HashSet;
class Main
{
// Program to convert set of integer to array of int in Java
public static void main(String args[])
{
Set<Integer> ints = new HashSet<>(Arrays.asList(1, 2, 3, 4, 5));
int[] primitive = ints.stream()
.mapToInt(Integer::intValue)
.toArray();
System.out.println(Arrays.toString(primitive));
}
}
Also in Java:
- jackson ignore values if empty
- java add a list to a list
- esponente in java
- substring in java
- java fileinputstream
- how to get a user to add to an arraylist in java
- how to collect objective in java
- remove unused imports intellij
- java round double to 2 decimal places
- http client java
- how lock horizontal orientation android
- java script find screen size of device
- Java array multidimensional hashcode
- java shuffle list
- libgdx move camera with touch
- javafx textarea size
- java repository sql find not in list
- java get folder content
- java how to call getReader twice
- java random seed
- spigot broadcast message
- trim() and split() in java
- add two numbers bitwise
- java split string on two or more spaces except for words in quotes