I need to input IntFunction such that Collections.toArray(IntFunction

I have a Set of Integer:

Set<Integer> itemSet = new HashSet<Integer>();
itemSet.add(1);
itemSet.add(3);
itemSet.add(5);

I want to convert it into an array of Integer where the value of each element in the array is double the value of the corresponding element in original Set. According to the above example, the array elements should be:

2, 6, 10

I tried:


Integer[] itemArr1 = itemSet.toArray((val) -> {
            Integer[] it = new Integer[]{val*2};
            return it;
            }
        );

but the values are not getting doubled.



Comments

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept