I have been developing Java for a few years now and every now and then
I will come across a useful class and find that it is Deprecated.
I think you mean methods. There are much more individual methods
deprecated than whole classes.
Sometimes I will look for an alternative but sometimes I don't.
Yes, sometimes there is non. E.g. in cases where it later turned out
that it is impossible to provide a reliable implementation across all
possible platforms.
OK - so I am sure that whatever useful functionality I found will be
present somewhere else, but my question is, is there actually any
reason not to use such classes?
Some are just deprecated to comply to naming conventions, e.g. for
JavaBeans (e.g. methods in AWT/Swing). But quite a number of methods are
deprecated because they never worked, never worked in a reliable, cross
platform way, or simply do something in the completely wrong way.
Fo example, thread handling has a bunch of deprecated methods because
they can't be implemented in a reliable way - and there is no
replacement. Date had a much to naive view of the date/time handling in
the world. Or String and IO Streams had methods which messed up
character encodings and didn't correctly distinguish between bytes and
chars.
JVM will surely never totally drop
these classes so why the need for the compiler to flag them?
Because using them is indeed often dangerous, for reasons explained
above. A deprecated warning from the compiler is something which
deserves an intensive look.
Regarding the complete removal of them from the VM. Well, at some point
Sun might indeed start to do this. Java would not be the only language
where features first had been declared obsolete or deprecated and then
removed a few years and major revisions later - to get rid of the cruft
which had accumulated over time.
Maybe it happens in ten years, maybe in one, or maybe never. But better
save than sorry.
/Thomas