Definition of Java interfaces and abstract classes

Source: Internet
Author: User
Tags constant definition define abstract

1. Define Interfaces

Use interfaces to define an interface. Similar definitions of interface definitions are similar. They are also divided into interface declarations and interface bodies. The interface body consists of constant definition and method definition. The basic format of the interface definition is as follows:

[Modifier] interface name [list of extends parent interface names] {

[Public] [static] [Final] constant;
[Public] [Abstract] method;
Modifier: Optional. It is used to specify the access permission for an interface. The optional value is public. If this parameter is omitted, the default access permission is used.
Interface Name: A required parameter used to specify the interface name. The interface name must be a valid Java identifier. Generally, uppercase letters are required.
Extends parent interface Name List: an optional parameter that specifies the parent interface to be defined. When the extends keyword is used, the parent interface name is a required parameter.

Method: The methods in the interface are defined and not implemented.

2. define abstract classes

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