Because they were in a hurry in the early days of Java and did not understand what the consequences would be of the four versions later.
From the very beginning, it was assumed that common functions should be part of the Java design, but the function was discarded as being too complex and not needed at that time. As a result, a lot of code in standard libraries was written with the assumption of non-general collections. For the Pizza prototype, Martin Odersky needed a language prototype to show how they could be made quite well, while maintaining almost perfect backward compatibility with Java code and bytecode. The prototype led to Java 5, in which collection classes were modified using generics so that the old code continued to work.
Unfortunately, if they were to retroactively make Properties inherit from Map<String, String> , then the previous valid code will stop working:
Map<Object, Object> x = new Properties() x.put("flag", true)
Why would someone do it at ease, but Sun's commitment to backward compatibility in Java has gone beyond the heroic to the meaningless.
What is now appreciated by most educated observers is that Properties should never inherit from Map at all. Instead, it should wrap itself around the Map , displaying only those map features that make sense.
Since the creation of Java, Martin Odersky has continued to create a new Scala language that is cleaner, inherits fewer errors, and breaks new ground in a number of areas. If you find that Java-niggles is annoying, take a look at it.
Marcus Downing May 17 '09 at 1:21 2009-05-17 01:21
source share