Set<Type> union = new HashSet<Type>(s1);
union.addAll(s2);
AND
Set <Type> union = new HashSet<Type>();
union.addAll(s1);
union.addAll(s2);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The difference here is much less than your previous question.
The first way should be faster because the original
Setwill not have to grow as much.The way you may want to do this is:
That way you won’t have to resize the new
Setat all. (Even though you may have some extra space)