10 Things You Didn't Know About Java. So, you’ve been working with Java since the very beginning?
Remember the days when it was called “Oak”, when OO was still a hot topic, when C++ folks thought that Java had no chance, when Applets were still a thing? I bet that you didn’t know at least half of the following things. Let’s start this week with some great surprises about the inner workings of Java. 1. There is no such thing as a checked exception That’s right! Today, everyone agrees that checked exceptions were a mistake. Do you want proof that the JVM doesn’t know such a thing? 01.public class Test { 04. public static void main(String[] args) { 05. doThrow(new SQLException()); 08. static void doThrow(Exception e) { 09. 12. 13. static <E extends Exception> 14. void doThrow0(Exception e) throws E { 15. throw (E) e; Not only does this compile, this also actually throws the SQLException, you don’t even need Lombok’s @SneakyThrows for that. More details about the above can be found in this article here, or here, on Stack Overflow. 2.
Collections Framework Enhancements in Java SE 8. Support for Lambda Expressions, Streams, and Aggregate Operations The Java Collections Framework has been updated to support lambda expressions, streams, and aggregate operations.
For more information on these topics, see the following pages: Enhancements in Java SE 8New and Enhanced APIs That Take Advantage of Lambda Expressions and Streams in Java SE 8Lambda Expressions (The Java Tutorials) Aggregate Operations (The Java Tutorials) Collections (The Java Tutorials) Performance Improvement for HashMaps with Key Collisions As part of the work for JEP 180, there is a performance improvement for HashMap objects where there are lots of collisions in the keys. The alternative String hash function added in 7u6 has been removed from JDK 8, along with the jdk.map.althashing.threshold system property.
In rare situations, this change could introduce a change to the iteration order of HashMap and HashSet. The Dark Side of Java 8. The dark side of Java 8 So far, we’ve been showing the thrilling parts of this new major release.
But there are also caveats. Lots of them. Things that … are confusing… are "wrong"… are omitted (for now)… are omitted (for long) There are always two sides to Java major releases. Lambda expressions were introduced quite elegantly. Overloading gets even worse Overloading, generics, and varargs aren’t friends. Optional Will Remain an Option in Java. Optional: A new Option in Java So far, we’ve been pretty thrilled with all the additions to Java 8.
All in all, this is a revolution more than anything before. But there are also one or two sore spots. One of them is how Java will never really get rid of Null: The billion dollar mistake. Java 8 Default Methods: What Can and Can Not Do? What default method is With the release of Java 8 you can modify interfaces adding new methods so that the interface remains compatible with the classes that implement the interface.
This is very important in case you develop a library that is going to be used by several programmers from Kiev to New York. Until the dawn of Java 8 if you published an interface in a library you could not add a new method without risking that some application implementing in the interface will break with the new version of the interface. The Wait is Over: JDK 8 is Here! JDK 8: General Availability. Two years, seven months, and eighteen days after the release of JDK 7, production-ready builds of JDK 8 are now available for download!
Thanks! A major new release of a software system as large as the JDK is the direct work of many hundreds of developers, with indirect contributions from thousands more. By way of thanks I’d like to mention the major contributors here specifically: Brian Goetz picked up my initial straw-man proposal to add lambda expressions and default methods to Java, built it up into a better proposal, led Project Lambda in the OpenJDK Community, designed the related streams API, and achieved consensus around all of this work in the JCP. Dan Smith and Maurizio Cimadamore made major contributions to the specification and the implementation.Stephen Colebourne‘s popular Joda Time library was the basis for his JSR 310 proposal to bring a new—and actually usable—date and time API to Java.
Launch!