29

I recently heard Vector is a Legacy class, then I read on a website that

Legacy classes are used to save Objects before Collections came.

So, why these are not called Deprecated classes, why Legacy?

Roman C
  • 49,761
  • 33
  • 66
  • 176
earthmover
  • 4,395
  • 10
  • 43
  • 74
  • Vector is rarely useful now but sometimes it can be used in a totally legit way.. – Denys Séguret Jan 13 '14 at 07:56
  • 1
    I feel that debating whether a class is or isn't "legacy" is mainly a question of opinion. Should we close this question as such ? – Denys Séguret Jan 13 '14 at 07:57
  • Its OK with down-votes, but can you give me the answer please? – earthmover Jan 13 '14 at 08:00
  • 5
    I think this question is a pretty interesting one. Don't understand the down votes, esp. without giving reasons? – Enno Shioji Jan 13 '14 at 08:05
  • 3
    There is no such thing a a "legacy class"; you will not find that term in the official docs or the official glossary. Its a made up term that people use to talk about old classes in java. What you will find are references to *legacy code* which refers to pre-generics. Also see http://stackoverflow.com/questions/2873254/difference-between-a-deprecated-and-a-legacy-api which is a DUP of this q – Brian Roach Jan 13 '14 at 08:08

2 Answers2

36

Legacy classes and interfaces are the classes and interfaces that formed the collections framework in the earlier versions of Java and how now been restructured or re-engineered. They are fully compatible with the framework.

Formally are not deprecated.

All legacy classes were re-engineered to support generic in JDK5.

Pratically are not deprecated, but there are other classes more appropriate.

Legacy = heritage of old java version.

venergiac
  • 7,469
  • 2
  • 48
  • 70
12

Early versions of java did not include Collections framework. Instead it defined several classes and one interface to store objects. When collection came these classes reengineered to support the Collection interfaces. These old classes are known are legacy classes. Vector is one of them. Others are Dictionary,HashTable,Properties, Stack

In this context, legacy means "should not be used anymore in new code". But you can if you want. And as they are not deprecated yet, they will be there for now at least.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
A Paul
  • 8,113
  • 3
  • 31
  • 61
  • HashTable still has the advantaged of being fully synchronized - on reads and writes. There are use cases where that is necessary. No other Collection class offers that. – IgorGanapolsky Mar 29 '17 at 12:58
  • 2
    @IgorGanapolsky what about using [`ConcurrentHashMap`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html)? – Salem Jan 06 '19 at 16:11