Java Object-Oriented _ interface

Source: Internet
Author: User

Java interface

Interface, is an abstract type, is a collection of abstract methods, interfaces are usually declared by interface. A class inherits the abstract method of an interface by inheriting the interface.

Interfaces are not classes, and the way they are written is similar to classes, but they are different concepts. Class describes the properties and methods of an object. The interface contains the methods to be implemented by the class.

Unless the class that implements the interface is an abstract class, the class defines all the methods in the interface.

Interfaces are similar to classes:

    • An interface can have multiple methods.
    • The interface file is saved in a file that ends in. java, and the filename uses the interface name.
    • The bytecode file for the interface is saved in a file that ends in a. class.
    • The corresponding bytecode file for the interface must be in the directory structure that matches the package name.

The interface keyword is used to declare an interface. Here is a simple example of an interface declaration.

/* File name: Nameofinterface.java */import java.  Lang. *;  Introduce package publicinterfacenameofinterface{//any type final, static field //abstract method }  

Java Object-Oriented _ interface

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.