Features of Java 5
Java 5 brought generics into the picture. Before generics, many of the data structures, such as Lists and Maps, were not typesafe. That is, you could have added a person and a vehicle into the same list and then tried to perform actions, which could result in errors.
Another important feature brought in by Java 5 was autoboxing, which helps the conversion between primitive type classes and corresponding wrapper classes. Enums, too, got a new life with Java 5. They could not only keep constant values, but could keep data and behavior as well.
Methods were provided with varargs. You were no longer forced to give the exact number of elements if they were of the same type. For example, you could simply write stringMethod(String... ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access