Please Read first! My question is in Java 8,
Clearly, in time of these questions, java 8 did not exist yet.
How to convert an ArrayList containing Integers to primitive int array? for today 10 years! Convert ArrayList<Byte> into a byte[] for today 8 years!
I have this code:
List<Byte> listByte = new ArrayList<>();
// fill the List with Byte Wrapper...
Those result in errors:
// 1. option
byte[] arrayByte = listByte.stream().map(B -> B.byteValue()).toArray();
// 2. option
byte[] arrayByte = listByte.toArray(new byte[0]);
Is there another method instead for loop method?