Friday, December 15, 2017

java 8: Convert a long array to String array


//Convert a primitive long[] to String[]
long[] pla = {1155L, 22334L, 559876L};

String[] spla = Arrays.stream(pla)
              .mapToObj(String :: valueOf)
              .toArray(String[] :: new);

//Convert a boxed Long[] to String[]
Long[] bla = LongStream.of(pla)
               .boxed().toArray(Long[] :: new);

String[] sbla = Arrays.stream(bla)
               .mapToLong(Long::longValue)
               .mapToObj(String::valueOf)
               .toArray(String[] :: new);

---------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment