Various versions of the new features Java

New features in each version of Java

Java 8 new features:

Lambda expressions
Lambda expression allows a method as an argument to a function, i.e. the function as a parameter passed into the process.

Interface increase the default method, etc.

Method references

Stream flow

Java 7 new features:

1. Java collection (the Collections) enhanced support, can be directly used [] {} is stored in the form of objects, using the [] in accordance with the form of the index key acquired object in the collection. Such as:

List list = [“item1”,”item2”];//存

String item = list [0]; // direct access

Set set = {“item1”,”item2”,”item3”};//存

Map<String,Integer> map = {“key1”:1,”key2”:2};//存

Int value=map[“key1”];//取

2. Available in String in Switch

3. The underlined values ​​can be used as the separator (automatically compile time is ignored)

4. Support binary numbers, such as: int binary = 0b1001_1001;

The method simplifies the calling of a variable parameter

6. generic class constructor call, generic parameters may be omitted, the compiler will automatically determined.

7.Boolean type reverse, null pointer security, participate bit computing

8.char type equals method: booleanCharacter.equalsIgnoreCase (char ch1, char ch2)

9. The safety arithmetic: Math.safeToInt (longv); Math.safeNegate (int v); Math.safeSubtract (long v1, int v2); Math.safeMultiply (int v1, int v2) ......

10 .Map collection supports concurrent requests, note HashTable are thread-safe, Map not thread-safe. But it also makes the update here support concurrency. Further, Map objects may be so defined: Map map = {name: "xxx", age: 18};

Java6 new features:

. \ 1 AWT added two new categories: Desktop and SystemTray, where the former is used by default to perform a program operation, such as using the default browser to the specified URL, using the default e-mail client to the specified mailbox mail, open with default application or edit a file (for example, use Notepad to open the txt file name suffix), with the default printer to print documents. The latter can be used to create a tray program in the system tray area

2. Use JAXB2 to implement the mapping between objects and XML, a Java object can be transformed into XML format, and vice versa

\ 3. StAX, parsing utilizing pull mode (pull-parsing) XML document API. Similar to SAX, is also based on event-driven model. The reason why the StAX added to JAXP family, because JDK6 in JAXB2 and JAX-WS 2.0 will use the StAX.

4. Using the Compiler API, dynamically compiled Java source files, such as JSP compiler engine is dynamic so modified without restarting the server.

5. Lightweight Http Server API, thus can build your own embedded HttpServer, it supports Http and Https protocol.

6. The process annotation plug-in API (PluggableAnnotation Processing API)

7. Console class provides for the development console program, located java.io package. Accordingly, etc. can be easily interact with Terminal under cmd or Linux under Windows.

8. support for scripting languages ​​such as: ruby, groovy, javascript

9.Common Annotations, was originally part of the J2EE 5.0 specification, and now part of it placed in J2SE 6.0

10. Derby embedded database

Java5 new features:

1. Automatic boxing and unboxing:

2. Enumeration

3. static import, such as: import staticjava.lang.System.out

4. The variable parameter (Varargs)

The introspection (the Introspector), primarily for operating the JavaBean properties by getXxx / setXxx. The general practice is to obtain information about an object by BeanInfo class Introspector, and then to get property descriptors (PropertyDescriptor) by BeanInfo, by this attribute descriptor can get getter / setter methods corresponding to a property, then we these methods can be invoked through reflection.

6. generics (the Generic) (including wild type / boundary type, etc.)

7.For-Each loop

8. notes

9. covariant return types: actual return a sub-type as the return type may be required

Released four original articles · won praise 0 · Views 519

Guess you like

Origin blog.csdn.net/The_Inertia/article/details/94059315