Java new features between 5 and 8

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wangbingfengf98/article/details/85164320

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 ......

猜你喜欢

转载自blog.csdn.net/wangbingfengf98/article/details/85164320