Merge multiple list of string in unique list in java 8

Edit2: : I have main data(list or array,it's no matter) like this:

{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}

I want to:

1-replace all values containing 3 with "julie"

2-all values that are val % 15 == 0 should be replaced with "jack".

3-also replace all values that are val % 5 == 0 should be replaced with "john" ,

Note: Without If Else Just With Java 8.

In the end I should have this data :

("1","2","julie","4","john","6","7","8","9","john","11","12","julie","14","jack","16","17","18","19","john")

for this issue I use stream and replaced these values with related string and i created 3 related list for each string:

1-Result for need1(replace all values containing 3 with "julie"): ("1","2","julie","4","5","6","7","8","9","10","11","12","julie","14","15","16","17","18","19","20")

2-Result for need2(all values that are val % 15 == 0 should be replaced with "jack"): ("1","2","3","4","5","6","7","8","9","10","11","12","13","14","jack","16","17","18","19","20")

3-Result for need3(replace all values that are val % 5 == 0 should be replaced with "john") :("1","2","3","4","john","6","7","8","9","john","11","12","13","14","john","16","17","18","19","john")

Now I want to have a final result such as below(either with mereg these lists or any other method without If&Else just with java8): :

("1","2","julie","4","john","6","7","8","9","john","11","12","julie","14","jack","16","17","18","19","john")

Thanks!



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation