New features of Java7 and JAVA8

Source: Internet
Author: User

To go down to the website:

http://blog.csdn.net/samjustin1/article/details/52268004

Java7 new Features

You can use a string in 1.switch

String s = "Test";   Switch (s) {case   "test":   System.out.println ("test");   Case "Test1":   System.out.println ("test1");   break;   Default:   System.out.println ("break");   break;   }

2. Using list<string> templist = new arraylist<> (); Generic instantiation type auto-inference

3. The collection is syntactically supported, not necessarily an array

Final list<integer> List = [1,2,3,4,5,6]

4. New tools to access environmental information

    File System.getjavaiotempdir ()//IO Temp folder      file System.getjavahomedir ()//JRE installation directory      file System.getuserhomedir ()///Current User directory      File system.getuserdir ()//directory where the Java process was started 5  

5,6,7 ...

Java8 new Features

1.Java 8 allows us to add a non-abstract method implementation to the interface, only need to use the default keyword, this feature is also called the extension method, the example is as follows:

Interface Formula {      double calculate (int a);         Default double sqrt (int a) {          return math.sqrt (a);      }  

2.LAMBDA-expression

3. Function-Type interface

New features of Java7 and JAVA8

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.