Java new features between 5 and 8
阿新 • • 發佈:2018-12-27
Java 5
1. for-each syntax
2. @override was introduced in Java 5, modified in Java 7
add this annotation and the compiler will produce an error message if you accidentally overload instead of overriding.
3. Variable-Length Argument Lists: a variable-length argument is specified by three periods(…). For Example,
public static void m(int ... varargs)
{
// method body
}
4. enum keyword
An especially nice feature is the way that enums can be used inside switch statements:
Java 8
1. forEach() which is heavily used.
(the Java compiler produces its own “assembly code,” but this code is run by the Java Virtual Machine rather than directly on a hardware CPU).
to be added later ......