JAVA9 new Features--syntax improvements: private methods for interfaces

Source: Internet
Author: User
Tags java se

1. Official feature

213:milling Project Coin

Support for private methods in interfaces is briefly in consideration for inclusion in Java SE 8 as part of the effort to add support for Lambda Expressions, but is withdrawn to enable better focus on higher priority tasks for Java S E 8. It's now proposed, that support for private interface methods be undertaken thereby enabling non abstract methods of a in Terface to share code between them.

2. Instructions for use

The methods in the specified interface in Java 8 can define static methods and default methods in addition to abstract methods. To some extent, the functionality of the interface is extended, and the interface is more like an abstract class at this point.

In Java 9, the interface is more flexible and powerful, and even the access modifiers of the method can be declared as private, and the method will not be part of the API you expose.

3. Examples of Use



Still Silicon Valley interviewer Song Hongkang
Links: Https://www.jianshu.com/p/ba217038abb4
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

JAVA9 new Features--syntax improvements: private methods for interfaces

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.