java - Collect Objects in Array -


i want filter cc addresses of array , want collect same array,

for example

string[] ccaddress = emails.split(";"); ccaddress = arrays.stream(ccaddress)                   .filter(adr -> "".equals(adr) == false)                   .collect(collectors.toarray);// ????? 

my question is, 'is there direct way collect filtered elements array in java8' ?

note : know can collect them list , write list.toarray() array not question.

did checked documentation?

you can use stream.toarray method:

string[] ccaddress = emails.split(";"); ccaddress = arrays.stream(ccaddress)         .filter(addr -> !addr.isempty())         .toarray(string[]::new); 

Comments