multi elements in a set.

Hello experts,

    Can I have one elements to appear several times in a set ? if not, how do I do it ?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

No - use a LIst
Mick BarryJava DeveloperCommented:
not if the elements are equals

you need to use a different collection, such as a List
Mick BarryJava DeveloperCommented:
Sets are for containing uniqueue elements, ie. no duplicates

what is it u are trying to achieve?
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Mick BarryJava DeveloperCommented:
If you see here, it explains what a Set is used for

Have a look thru here to determine the type of Collection that best suits your needs:
meow00Author Commented:
So I have two collections:

 list1 = "A", "A", "B", "C", "C"
 list2 = "C", "A", "A", "C","B"

 if the order I added to the list are different ...
 how do I check if they are the same ( ps. I need the above to list to be EQUAL) ... can list do that ?

sort them first then apply list1.equals(list2)
Mick BarryJava DeveloperCommented:
use an ArrayList and first sort them
Mick BarryJava DeveloperCommented:
if (list1.equals(list2))
Mick BarryJava DeveloperCommented:
you couls also use the List's containsAll() method

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Add a new class with weight value
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.