最初Project Coin增强了对集合的支持,例如list[3]
代替list.get(3)
和map["hello"] = 27
代替,map.put("hello", 27)
但它们不在 jdk7 中。他们会在jdk8中吗?我找不到是或否的明确答案。
1 回答
Brian Goetz briefly mentions list, set, map (and other possible) literals in this post in the Project Lambda mailing list from 30th May:
http://mail.openjdk.java.net/pipermail/lambda-dev/2012-May/004979.html
To illustrate what I mean by "we could do better", here's an alternative proposal that gets far more mileage out of #: structured literals. While these plans are not in place for 8, we have already stated our desire to add structured literals for lists, maps, sets, etc. # as a prefix symbol, combined with delimiters, gives us a far higher return-on-syntax as a structured literal builder (as a bonus, # is already associated with structured literals in a lot of languages, going all the way back to many early assembly languages where # was the immediate addressing mode.)
So to me it seems that even the collection literals won't make it into JDK 8, let alone the get/set/put operators. It's a pity.
Also I do not see anything relating to collection literals or new operators in the list of JDK 8 milestones: