The advantage is that it then becomes easier (or more accurately, requires fewer syntactical changes) to perform other functional operations at the same time.
Say later on you just wanted the even numbers in the set, you could then do that trivially with a filter:
Set<Integer> myset = mylist.stream()
.filter(p -> p%2==0)
.collect(Collectors.toSet());
If you'd done it the traditional way, then you'd either need to convert it to the above syntax, or write an additional loop to go through and pull out only the values that you wanted.
(This doesn't mean it's always better - there may be cases where you want to discourage someone changing the code at a later date to filter out values, in which case you could argue the traditional way is still preferable.)
new HashSet(mylist). If you want to filter or map your stream, then there is an advantage to it.HashSetso that it works efficiently. Doing it withstream()- not so much.HashSets constructor initialises the internal map to a reasonable size before inserting elements?new HashSet(myList)is easier to understand thanmyList.stream().collect(Collectors.toSet()), no matter how excited the functional programming evangelists get about the latter.