IBM Java 7 new features and configuration in was 8.5

Source: Internet
Author: User
Tags file system new features resource java se

What is Java 7---High level goal?

The release of the Java version of almost all platforms involves all aspects of the Java language itself and the JVM. So for Java 7, from the JSR draft, we get the high-level goal of Java 7:

Compatibility-Any program running on previous versions must be able to run in Java SE 7 without making any changes;

Development efficiency-improve the development efficiency, the smallest learning curve;

Performance-a new parallel API interface that introduces a true asynchronous I/O API that makes I/O-intensive applications have better performance;

Applicability-the ability to speed up the performance of other dynamic languages on Java virtual machines;

The ―java SE 7 will include a new, flexible file system API as part of the JSR203.

Basic new features of Java 7

Enhancements to the Java language features (JSR334)

Project Coin mainly makes some minor improvements to the Java language to improve the productivity of Java developers:

String type allowed in Switch statement

Listing 1. String type examples are allowed in Switch statements

Switch (myString) {case 
    ' one ': <do something>; break; 
    Case "Two": <do something else>; break; 
    Default: <do something generic>; 
}

Provides type inference for creation of common type instances

Listing 2. Provides type inference examples for creation of common type instances

map<string,mytype> foo = new map<string,mytype> (); 
    
becomes: 
    
Map <String,MyType> foo = new map<> (); 
    
    
}

Multi Catch to handle a variety of exception types

Listing 3. Multi Catch to handle a variety of exception types examples

Java 6: 
 Try { 
   ... 
   } catch (Exception a) { 
        handle (a); 
   } catch (Error b) { 
       handle (b); 
} 
    
Java 7: 
    
Try { 
  ...
} catch (Exception | Error a) { 
  handle (a); 
}

Binary constants and numeric constants examples

0b10011010 34_409_066

Automatic resource management mechanism

In the Java program, handling all possible failure paths is difficult, and closing resources is also relatively difficult, so in the Java 7 implementation, resource management obtains the help of compilers, by defining a resource interface that allows the compiler to automatically shut down resources when appropriate, freeing up resources such as memory.

Automatic Resource Management Example

Try (inputstream inFile = new FileInputStream

(afilename); 
   OutputStream outfile = new FileOutputStream (afilename)) { 
   byte[] buf = new Byte[buf_size]; 
   int readbytes; 
while ((Readbytes = Infile.read (buf)) >= 0) 
  infile.write (buf, readbytes); 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.