Java 1.5 Methods
- As of Java 1.5, users can perform a for-each loop upon any object which implements the Collection interface with the following syntax.
for (Object obj : Collection collection) { /* DO */ }
(see references 1) - Collections support generics in order to reduce the need for explicit casts, with the following syntax.
Collection<String> dataStructure = new Collection<String>();
(see references 1) - Collections now also support autoboxing. This new feature allows primitive values, such as int, to be automatically cast into and out of an appropriate class, such as Integer, when needed. This is done without the use of explicit casting by the programmer.
- The lang and util libraries include a variety of new classes and methods for them. ProcessBuilder provides a easier interface for invoking subprocesses, particularly those with a where the process environment is modified from that of its parent. Formatter provides methods for string justification, alignment, and common formats for different types of data, including date/times. Scanner provides a way to load objects and string from text, and provides Java methods for performing a regular expression search. A wide variety of new classes and methods exist to simplify programming with multiple concurrent threads.
- The Java Database Connectivity API has been enhanced to include a RowSet interface. The RowSet interface provides easier methods for passing data from a database connection between different components. It comes with a five standard implementations and support for the creation of more when needed.
- The BigDecimal class now has support for performing floating point calculations with a fixed precision, and the Math and StrictMath libraries now include methods for performing sinh, cosh, tanh, cube root, and base 10 logarithms. Finally, there is now support for floating point operations using hexadecimal notation in the Float and Double classes.
- Java 2D has enhanced methods for printer support on Linux and Solaris and added new methods for creating fonts from files and data streams. As of Java 1.5, Java Sound is now ported to all platforms which can are supported by the Java virtual machine.
For-each Loop
Generics
Autoboxing
New Classes in Lang and Util Libraries
JDBC Enhancements
Math
Sound and 2D
Source...