java collection related questions

I have below  java collection related questions. Please advise
why no concrete classcan  implement collection interface
what is fifference between collection, collections.

why vector, stack ,dictionary,Hashtable(why t small? ), Preoprties etc called called legacy classes''


why heterogeneous objects not allowed in treeset and treemap

Please advise
LVL 7
gudii9Asked:
Who is Participating?

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

x
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.

dpearsonCommented:
Sounds like 4 unrelated questions?

I'll answer 1 and 3:

why no concrete class can  implement collection interface
A concrete class can implement Collection if it wants.  It's not prevented - just in the Java libraries they defined more specialized interfaces (List, Map etc.) and then implemented those.  That way Lists and Maps have some things in common like "isEmpty()" and "contains".

why vector, stack ,dictionary,Hashtable(why t small? ), Preoprties etc called called legacy classes''
These are legacy classes because Sun wrote new, better versions later, so you should stop using these and switch to the newer better alternatives in most cases.  E.g. HashMap is a better version of Hashtable and ArrayList is a better version of Vector.  They didn't take out the old classes, because that would break existing code that was using the older versions.

It's just a case of time moving on and their engineers figuring out better solutions over time.

Doug
0

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
zzynxSr. Software engineerCommented:
what is fifference between collection, collections.
First I have to correct you it is Collection and Collections (with capitals)
1) Collection is an interface.
    It is the root interface in Java's collection hierarchy. A collection represents a group of objects, known as its elements.
    A lot of classes implement the Collection interface. ArrayList, HashSet, LinkedList, TreeSet to name a few.
    (cf. The Collection interface)

2) Collections is a java class that consists exclusively of static handy utility methods that operate on or return collections.
   (cf. The Collections class)

why heterogeneous objects not allowed in TreeSet and TreeMap
Sorted collections (like TreeSet and TreeMap) don't allow addition of heterogeneous elements as they are not comparable. You can't compare apples to oranges.
0
gudii9Author Commented:
Hashtable(why t small? )

please advise
0
dpearsonCommented:
Hashtable(why t small? )

You'd have to ask the guys at Sun (Oracle now) :)

Naming conventions weren't as well defined when Java first appeared.  I wouldn't read much into this.
0
zzynxSr. Software engineerCommented:
Thanx 4 axxepting
0
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
Java EE

From novice to tech pro — start learning today.