Convert old "into" code to the collectors

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Jan 16 07:05:22 PST 2013


On 16/01/13 14:34, Marcos Antonio wrote:
> Hello, everybody!
>
> Before build b73 I had code like this:
>
> List<PropriedadeChavePai> propriedades = new ArrayList<>();
>
> chave.getPropriedadesChavePai().stream().
>      map(PropriedadeChavePai::new).
>      into(propriedades);
>
> Now I'm having trouble trying to convert it to use the new Collectors. I have tried something like this:
>
> chave.getPropriedadesChavePai().stream().
>      map(PropriedadeChavePai::new).
>      collect(Collectors.toCollection(propriedades));
>
> but it didn't work and I couldn't figure out the right thing to do.
>
> Thank you in advance.
>
> Marcos 		 	   		
>
What do you mean it didn't work? Did you get an error message from the 
compiler? If so, can you please paste it?

Maurizio


More information about the lambda-dev mailing list