‘Programming in Scala’ states:
…maps in Scala are not language syntax. They are library abstractions that
you can extend and adapt.
Is it in any way different from Java. Java too offers different types of Map, like HashMap, LinkedHashMap etc? Or am I missing some finer point here which author wants to convey?
They mean that in Scala you can construct a Map like
Map("a" -> 1, "b" -> 2, "c" -> 3). This syntax is not built into the compiler but is just part of a library. In most other languages the syntax for Map literals is built into the compiler and a developer cannot define something similar for their own data types. Java on the other hand has no user-friendly syntax for Maps at all if I’m not mistaken.
At least for this occurrence, it is clear from the context that this is in comparison with scripting languages like Perl, Python and Ruby. As for Java, see @Jasper-M’s answer. There’s factory methods like
Map#ofEntries() (since Java 9), but this is still a far cry from Scala syntax.