Java Core Technology Volume One note 6.1. Interface lambda expression inner class

Source: Internet
Author: User
Tags comparable

6.1.2 interface is not a class, cannot instantiate an interface, but can declare the variable of the interface; comparable x; The interface variable must refer to the class object that implements the interface; x = new Employee ();

Checks whether an object belongs to a particular class (instanceof);

Checks whether an object belongs to a particular interface (instance), if (AnObject instanceof comparable) {...}

6.1.3 Interfaces and abstract classes

An abstract class can only extend one class (single inheritance);

6.1.4 static method

A way to construct a file or directory by a sequence of strings, such as Paths.get ("jdk1.8.0", "JRE", "bin")

public interface Path
{
public static Path Get (String first...more)
{
Return Filesystems.getdefault (). GetPath (First, more);
}
...
}

6.1.5 Default method

You can provide a default implementation for an interface method.

public interface comparable<t>{

Default int Comparableto (T other) {return o;}

}

6.1.6 Resolving default method conflicts

If you first define a method as the default method in one interface, and then define the same method in the superclass or another interface?

1) Super class priority. If the superclass provides a specific method, the default method with the same name and with the same parameter type is ignored.

2) interface conflicts. If a hyper-interface provides a default method, and the other interface provides a method with the same name and the same parameter type, this method must be overridden to resolve the conflict.

Java Core Technology Volume One note 6.1. Interface lambda expression inner class

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.